Throw lookup_failed() when hostname resolving fails.
This commit is contained in:
parent
5861ff2dc6
commit
ebe928e7e1
|
@ -224,21 +224,24 @@ UID SimExternalConnection::getDebugID() const {
|
|||
std::vector<NetworkAddress> SimExternalConnection::resolveTCPEndpointBlocking(const std::string& host,
|
||||
const std::string& service) {
|
||||
ip::tcp::resolver resolver(ios);
|
||||
ip::tcp::resolver::query query(host, service);
|
||||
auto iter = resolver.resolve(query);
|
||||
decltype(iter) end;
|
||||
std::vector<NetworkAddress> addrs;
|
||||
while (iter != end) {
|
||||
auto endpoint = iter->endpoint();
|
||||
auto addr = endpoint.address();
|
||||
if (addr.is_v6()) {
|
||||
addrs.emplace_back(IPAddress(addr.to_v6().to_bytes()), endpoint.port());
|
||||
} else {
|
||||
addrs.emplace_back(addr.to_v4().to_ulong(), endpoint.port());
|
||||
try {
|
||||
auto iter = resolver.resolve(host, service);
|
||||
decltype(iter) end;
|
||||
std::vector<NetworkAddress> addrs;
|
||||
while (iter != end) {
|
||||
auto endpoint = iter->endpoint();
|
||||
auto addr = endpoint.address();
|
||||
if (addr.is_v6()) {
|
||||
addrs.emplace_back(IPAddress(addr.to_v6().to_bytes()), endpoint.port());
|
||||
} else {
|
||||
addrs.emplace_back(addr.to_v4().to_ulong(), endpoint.port());
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
++iter;
|
||||
return addrs;
|
||||
} catch (...) {
|
||||
throw lookup_failed();
|
||||
}
|
||||
return addrs;
|
||||
}
|
||||
|
||||
ACTOR static Future<std::vector<NetworkAddress>> resolveTCPEndpointImpl(std::string host, std::string service) {
|
||||
|
|
|
@ -1892,21 +1892,24 @@ Future<std::vector<NetworkAddress>> Net2::resolveTCPEndpoint(const std::string&
|
|||
|
||||
std::vector<NetworkAddress> Net2::resolveTCPEndpointBlocking(const std::string& host, const std::string& service) {
|
||||
tcp::resolver tcpResolver(reactor.ios);
|
||||
tcp::resolver::query query(host, service);
|
||||
auto iter = tcpResolver.resolve(query);
|
||||
decltype(iter) end;
|
||||
std::vector<NetworkAddress> addrs;
|
||||
while (iter != end) {
|
||||
auto endpoint = iter->endpoint();
|
||||
auto addr = endpoint.address();
|
||||
if (addr.is_v6()) {
|
||||
addrs.emplace_back(IPAddress(addr.to_v6().to_bytes()), endpoint.port());
|
||||
} else {
|
||||
addrs.emplace_back(addr.to_v4().to_ulong(), endpoint.port());
|
||||
try {
|
||||
auto iter = tcpResolver.resolve(host, service);
|
||||
decltype(iter) end;
|
||||
std::vector<NetworkAddress> addrs;
|
||||
while (iter != end) {
|
||||
auto endpoint = iter->endpoint();
|
||||
auto addr = endpoint.address();
|
||||
if (addr.is_v6()) {
|
||||
addrs.emplace_back(IPAddress(addr.to_v6().to_bytes()), endpoint.port());
|
||||
} else {
|
||||
addrs.emplace_back(addr.to_v4().to_ulong(), endpoint.port());
|
||||
}
|
||||
++iter;
|
||||
}
|
||||
++iter;
|
||||
return addrs;
|
||||
} catch (...) {
|
||||
throw lookup_failed();
|
||||
}
|
||||
return addrs;
|
||||
}
|
||||
|
||||
bool Net2::isAddressOnThisHost(NetworkAddress const& addr) const {
|
||||
|
|
Loading…
Reference in New Issue