hints.ai_flags = AI_ADDRCONFIG;
hints.ai_family = 0;
- struct addrinfo* res = nullptr;
- auto ret = getaddrinfo(name.c_str(), nullptr, &hints, &res);
- // We pick the first address returned for now.
- // XXX This might trigger unwanted "changes detected "if the sort order varies
- if (ret == 0) {
- auto address = ComboAddress{res->ai_addr, res->ai_addrlen};
- freeaddrinfo(res);
- return address;
+ struct addrinfo* res0 = nullptr;
+ auto ret = getaddrinfo(name.c_str(), nullptr, &hints, &res0);
+ // We pick the first address after sorting for now, no handling of multiple addresses or AF selection.
+ vector<ComboAddress> vec;
+ if (ret != 0) {
+ return {};
+ }
+ auto* res = res0;
+ while (res != nullptr) {
+ try {
+ auto address = ComboAddress{res->ai_addr, res->ai_addrlen};
+ vec.emplace_back(address);
+ }
+ catch (...) {
+ }
+ res = res->ai_next;
+ }
+ freeaddrinfo(res0);
+ if (!vec.empty()) {
+ std::sort(vec.begin(), vec.end());
+ return vec.at(0);
}
return {};
}
if (buffer.empty()) {
return {};
}
- MOADNSParser parser(false, reinterpret_cast<char*>(buffer.data()), buffer.size()); // NOLINT
+
+ MOADNSParser parser(false, static_cast<const char*>(static_cast<void*>(buffer.data())), buffer.size());
if (parser.d_header.rcode != RCode::NoError || parser.d_answers.size() != 1) {
return {};
}
while (!stop) {
const time_t startTime = time(nullptr);
time_t wakeTime = startTime;
+ // The expresion wakeTime - startTime is equal to the total amount of time slept
while (wakeTime - startTime < d_interval) {
std::unique_lock lock(mutex);
time_t remaining = d_interval - (wakeTime - startTime);
// Lookup a name which must be already registered
ComboAddress lookup(const std::string& name);
- // When an instance is created, it will runn a refresh thread, stop it wit this method
+ // When an instance is created, it will run a refresh thread, stop it with this method
void stopRefresher();
// And restart it again
void startRefresher();
// Wipe one or all names
void wipe(const std::string& name = "");
- // Did we se a cahnage? Calling this functino will reset the flag.
+ // Did we see a change? Calling this function will reset the flag.
bool changeDetected();
private:
Starting with version 5.1.0, names can be used if
:ref:`setting-yaml-recursor.system_resolver_ttl` is set.
-The names will be resolved using the system resolver and an automatic refresh of the forwarding zones will happend if a name starts resolving to a new address.
+The names will be resolved using the system resolver and an automatic refresh of the forwarding zones will happen if a name starts resolving to a new address.
Auth Zone
^^^^^^^^^