0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-28 11:48:54 +02:00

modules/s_dns: Improve ipport query deduction related.

This commit is contained in:
Jason Volk 2019-03-24 13:20:40 -07:00
parent a1ac9cb356
commit 4677e5f443

View file

@ -38,13 +38,30 @@ ircd::net::dns::resolve(const hostport &hp,
dns::opts opts(opts_);
opts.qtype = opts_.qtype?: 33; // default to SRV
opts.nxdomain_exceptions = false;
net::dns::callback_one handler
{
std::bind(&handle_resolve_SRV_ipport, ph::_1, ph::_2, opts, std::move(callback))
};
resolve(hp, opts, std::move(handler));
if(opts.qtype == 33)
{
opts.nxdomain_exceptions = false;
net::dns::callback_one handler
{
std::bind(&handle_resolve_SRV_ipport, ph::_1, ph::_2, opts, std::move(callback))
};
resolve(hp, opts, std::move(handler));
}
else if(opts.qtype == 1 || opts.qtype == 28)
{
net::dns::callback_one handler
{
std::bind(&handle_resolve_A_ipport, ph::_1, ph::_2, opts, port(hp), std::move(callback))
};
resolve(hp, opts, std::move(handler));
}
else throw error
{
"Query type:%u not valid for ipport result callback.", opts.qtype
};
}
void
@ -162,7 +179,9 @@ ircd::net::dns::handle_resolve_A_ipport(const hostport &hp,
const json::string &ip
{
rr.get("ip", "0.0.0.0"_sv)
opts.qtype == 28?
rr.get("ip", ":::0"_sv):
rr.get("ip", "0.0.0.0"_sv)
};
const ipport &ipport