0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-30 02:32:43 +01:00

ircd::server: Fix port number propagation conditions across resolution handlers.

ircd::server: Condition to skip SRV when explicit port number specified.
This commit is contained in:
Jason Volk 2020-03-06 10:56:20 -08:00
parent 0e25a2e055
commit adcf3215f1

View file

@ -1212,7 +1212,7 @@ ircd::server::peer::resolve(const hostport &hostport)
net::dns::opts opts; net::dns::opts opts;
// Figure out the initial query type. Most of the time it's SRV. // Figure out the initial query type. Most of the time it's SRV.
opts.qtype = net::service(hostport)? opts.qtype = net::service(hostport) && !net::port(hostport)?
33: // SRV 33: // SRV
peer::enable_ipv6 && net::enable_ipv6? peer::enable_ipv6 && net::enable_ipv6?
28: // AAAA 28: // AAAA
@ -1317,16 +1317,18 @@ try
} }
// Target for the next address record query. // Target for the next address record query.
const hostport &target const hostport &target
{ {
rr.has("tgt")? rr.has("tgt")?
rstrip(unquote(rr.at("tgt")), '.'): rstrip(unquote(rr.at("tgt")), '.'):
host(hp), host(hp),
rr.has("port")? rr.has("port")?
rr.get<uint16_t>("port"): rr.get<uint16_t>("port"):
port(hp) port(remote)?
}; port(remote):
port(hp)
};
// Save the port from the SRV record to a class member because it won't // Save the port from the SRV record to a class member because it won't
// get carried through the next A/AAAA query. // get carried through the next A/AAAA query.
@ -1409,7 +1411,7 @@ try
assert(!net::dns::is_error(rr)); assert(!net::dns::is_error(rr));
this->remote = net::ipport this->remote = net::ipport
{ {
unquote(rr.at("ip")), net::port(this->remote) unquote(rr.at("ip")), port(this->remote)?: port(target)
}; };
open_opts.ipport = this->remote; open_opts.ipport = this->remote;
@ -1431,7 +1433,7 @@ catch(const std::exception &e)
} }
void void
ircd::server::peer::handle_resolve_A(const hostport &, ircd::server::peer::handle_resolve_A(const hostport &target,
const json::array &rrs) const json::array &rrs)
try try
{ {
@ -1473,7 +1475,7 @@ try
// Save the results of the query to this object instance. // Save the results of the query to this object instance.
this->remote = net::ipport this->remote = net::ipport
{ {
unquote(rr.at("ip")), net::port(this->remote) unquote(rr.at("ip")), port(this->remote)?: port(target)
}; };
open_opts.ipport = this->remote; open_opts.ipport = this->remote;