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:
parent
a1ac9cb356
commit
4677e5f443
1 changed files with 26 additions and 7 deletions
|
@ -38,13 +38,30 @@ ircd::net::dns::resolve(const hostport &hp,
|
||||||
|
|
||||||
dns::opts opts(opts_);
|
dns::opts opts(opts_);
|
||||||
opts.qtype = opts_.qtype?: 33; // default to SRV
|
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
|
void
|
||||||
|
@ -162,7 +179,9 @@ ircd::net::dns::handle_resolve_A_ipport(const hostport &hp,
|
||||||
|
|
||||||
const json::string &ip
|
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
|
const ipport &ipport
|
||||||
|
|
Loading…
Reference in a new issue