2022-07-28 16:07:38 +00:00
|
|
|
#include "platform.hpp"
|
2022-06-22 16:14:33 +00:00
|
|
|
|
|
|
|
namespace llarp::dns
|
|
|
|
{
|
|
|
|
void
|
|
|
|
Multi_Platform::add_impl(std::unique_ptr<I_Platform> impl)
|
|
|
|
{
|
|
|
|
m_Impls.emplace_back(std::move(impl));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2022-07-28 16:07:38 +00:00
|
|
|
Multi_Platform::set_resolver(unsigned int index, llarp::SockAddr dns, bool global)
|
2022-06-22 16:14:33 +00:00
|
|
|
{
|
2022-09-16 15:01:42 +00:00
|
|
|
if (m_Impls.empty())
|
2022-09-16 16:20:24 +00:00
|
|
|
return;
|
2022-06-22 16:14:33 +00:00
|
|
|
size_t fails{0};
|
|
|
|
for (const auto& ptr : m_Impls)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2022-07-28 16:07:38 +00:00
|
|
|
ptr->set_resolver(index, dns, global);
|
2022-06-22 16:14:33 +00:00
|
|
|
}
|
|
|
|
catch (std::exception& ex)
|
|
|
|
{
|
2022-09-12 16:17:22 +00:00
|
|
|
log::warning(log::Cat("dns"), "{}", ex.what());
|
2022-06-22 16:14:33 +00:00
|
|
|
fails++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fails == m_Impls.size())
|
|
|
|
throw std::runtime_error{"tried all ways to set resolver and failed"};
|
|
|
|
}
|
|
|
|
} // namespace llarp::dns
|