mirror of
https://github.com/matrix-construct/construct
synced 2024-12-26 15:33:54 +01:00
ircd::net::dns: Add conditions and assertions on inputs to SRV query generator.
This commit is contained in:
parent
ae8b2bc0f8
commit
2116567281
1 changed files with 18 additions and 8 deletions
|
@ -172,22 +172,32 @@ ircd::net::dns::make_SRV_key(const mutable_buffer &out,
|
|||
const opts &opts)
|
||||
{
|
||||
thread_local char tlbuf[2][rfc1035::NAME_BUFSIZE];
|
||||
|
||||
if(!opts.srv)
|
||||
return fmt::sprintf
|
||||
if(unlikely(!service(hp) && !opts.srv))
|
||||
throw error
|
||||
{
|
||||
out, "_%s._%s.%s",
|
||||
tolower(tlbuf[0], service(hp)),
|
||||
opts.proto,
|
||||
tolower(tlbuf[1], host(hp)),
|
||||
"Service name or query string option is required for SRV lookup."
|
||||
};
|
||||
else
|
||||
|
||||
assert(host(hp));
|
||||
if(!service(hp))
|
||||
{
|
||||
assert(opts.srv);
|
||||
return fmt::sprintf
|
||||
{
|
||||
out, "%s%s",
|
||||
opts.srv,
|
||||
tolower(tlbuf[1], host(hp))
|
||||
};
|
||||
}
|
||||
|
||||
assert(service(hp));
|
||||
return fmt::sprintf
|
||||
{
|
||||
out, "_%s._%s.%s",
|
||||
tolower(tlbuf[0], service(hp)),
|
||||
opts.proto,
|
||||
tolower(tlbuf[1], host(hp)),
|
||||
};
|
||||
}
|
||||
|
||||
ircd::json::object
|
||||
|
|
Loading…
Reference in a new issue