string EDNSCookiesOpt::toDisplayString() const
{
std::ostringstream str;
- str << makeHexDump(client, "");
+ str << makeHexDump(client, "");
if (!server.empty()) {
str << '|';
if (server.length() != 16) {
static bool g_cookies = false;
-void setAuthCookies(bool flag)
+void enableOutgoingCookies(bool flag)
{
g_cookies = flag;
}
static LockGuarded<CookieStore> s_cookiestore;
-std::string clearCookies()
+void clearCookies()
{
auto lock = s_cookiestore.lock();
lock->clear();
- return "";
}
void pruneCookies(time_t cutoff)
auto lock = s_cookiestore.lock();
copy = *lock;
}
- return CookieStore::dump(copy, fileDesc);
+ return copy.dump(fileDesc);
}
void remoteLoggerQueueData(RemoteLoggerInterface& rli, const std::string& data)
{
dnsOverTLS = SyncRes::s_dot_to_port_853 && remote.getPort() == 853;
- connection = t_tcp_manager.get(std::make_pair(remote, localBind));
+ connection = t_tcp_manager.get({remote, localBind});
if (connection.d_handler) {
return false;
}
auto found = lock->find(address);
if (found == lock->end()) {
- // We receivd cookie (we might have sent one out) but the server is not in the table?
+ // We received cookie (we might have sent one out) but the server is not in the table?
// This is a case of cannot happen, unless rec_control clear-cookies was called
VLOG(log, "Cookie from " << address.toString() << " not found back in table" << endl);
lwr.d_rcode = RCode::FormErr;
}
else {
VLOG(log, "Malformed cookie in reply from " << address.toString() << ", dropping as if was a timeout" << endl);
- // Do something special if we get malformed repeatedly? And or consider current status?
+ // Do something special if we get malformed repeatedly? And/or consider current status?
lwr.d_validpacket = false;
++t_Counters.at(rec::Counter::cookieMalformed);
return {true, LWResult::Result::Timeout};
if (found != lock->end()) {
switch (found->getSupport()) {
case CookieEntry::Support::Probing:
- VLOG(log, "No cookie in repy from " << address.toString() << ", was probing, setting support to Unsupported" << endl);
+ VLOG(log, "No cookie in reply from " << address.toString() << ", was probing, setting support to Unsupported" << endl);
found->setSupport(CookieEntry::Support::Unsupported, now->tv_sec);
++t_Counters.at(rec::Counter::cookiesUnsupported);
break;
case CookieEntry::Support::Unsupported:
// We could have detected the server does not support cookies in the meantime
- VLOG(log, "No cookie in repy from " << address.toString() << ", cookie state is Unsupported, fine" << endl);
+ VLOG(log, "No cookie in reply from " << address.toString() << ", cookie state is Unsupported, fine" << endl);
break;
case CookieEntry::Support::Supported:
// RFC says: ignore replies not containing any cookie info, equivalent to timeout
- VLOG(log, "No cookie in repy from " << address.toString() << ", cookie state is Supported, dropping packet as if it timed out)" << endl);
+ VLOG(log, "No cookie in reply from " << address.toString() << ", cookie state is Supported, dropping packet as if it timed out)" << endl);
return LWResult::Result::Timeout;
break;
}
}
else {
- VLOG(log, "No cookie in repy from " << address.toString() << ", cookie state is Unknown, dropping packet as if it timed out" << endl);
+ VLOG(log, "No cookie in reply from " << address.toString() << ", cookie state is Unknown, dropping packet as if it timed out" << endl);
return LWResult::Result::Timeout;
}
}
LWResult::Result asyncresolve(const OptLog& log, const ComboAddress& address, const DNSName& domain, int type, bool doTCP, bool sendRDQuery, int EDNS0Level, struct timeval* now, boost::optional<Netmask>& srcmask, const ResolveContext& context, const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, const std::shared_ptr<std::vector<std::unique_ptr<FrameStreamLogger>>>& fstrmLoggers, const std::set<uint16_t>& exportTypes, LWResult* lwr, bool* chained);
uint64_t dumpCookies(int fileDesc);
-std::string clearCookies();
+void clearCookies();
void pruneCookies(time_t cutoff);
-void setAuthCookies(bool flag);
+void enableOutgoingCookies(bool flag);
ind.erase(ind.begin(), ind.upper_bound(cutoff));
}
-uint64_t CookieStore::dump(const CookieStore& copy, int fileDesc)
+uint64_t CookieStore::dump(int fileDesc) const
{
int newfd = dup(fileDesc);
if (newfd == -1) {
uint64_t count = 0;
fprintf(filePtr.get(), "; cookie dump follows\n; server\tlocal\tcookie\tsupport\tts\n");
- for (const auto& entry : copy) {
+ for (const auto& entry : *this) {
count++;
timebuf_t tmp;
fprintf(filePtr.get(), "%s\t%s\t%s\t%s\t%s\n",
static std::string toString(Support support)
{
- static const std::array<std::string, 4> names = {
+ static const std::array<std::string, 3> names = {
"Unsupported",
"Supported",
"Probing"};
{
public:
void prune(time_t cutoff);
- static uint64_t dump(const CookieStore&, int fileDesc);
+ [[nodiscard]] uint64_t dump(int fileDesc) const;
};
g_paddingOutgoing = ::arg().mustDo("edns-padding-out");
g_ECSHardening = ::arg().mustDo("edns-subnet-harden");
- setAuthCookies(::arg().mustDo("outgoing-cookies"));
+ enableOutgoingCookies(::arg().mustDo("outgoing-cookies"));
RecThreadInfo::setNumDistributorThreads(::arg().asNum("distributor-threads"));
RecThreadInfo::setNumUDPWorkerThreads(::arg().asNum("threads"));
}
}
-void TCPOutConnectionManager::store(const struct timeval& now, const pair_t& pair, Connection&& connection)
+void TCPOutConnectionManager::store(const struct timeval& now, const endpoints_t& pair, Connection&& connection)
{
++connection.d_numqueries;
if (s_maxQueries > 0 && connection.d_numqueries >= s_maxQueries) {
d_idle_connections.emplace(pair, std::move(connection));
}
-TCPOutConnectionManager::Connection TCPOutConnectionManager::get(const pair_t& pair)
+TCPOutConnectionManager::Connection TCPOutConnectionManager::get(const endpoints_t& pair)
{
if (d_idle_connections.count(pair) > 0) {
auto connection = d_idle_connections.extract(pair);
size_t d_numqueries{0};
};
- using pair_t = std::pair<ComboAddress, std::optional<ComboAddress>>;
+ using endpoints_t = std::pair<ComboAddress, std::optional<ComboAddress>>;
- void store(const struct timeval& now, const pair_t& pair, Connection&& connection);
- Connection get(const pair_t& pair);
+ void store(const struct timeval& now, const endpoints_t& pair, Connection&& connection);
+ Connection get(const endpoints_t& pair);
void cleanup(const struct timeval& now);
[[nodiscard]] size_t size() const
private:
// This does not take into account that we can have multiple connections with different hosts (via SNI) to the same IP.
// That is OK, since we are connecting by IP only at the moment.
- std::multimap<pair_t, Connection> d_idle_connections;
+ std::multimap<endpoints_t, Connection> d_idle_connections;
};
extern thread_local TCPOutConnectionManager t_tcp_manager;
return doDumpCache(socket, begin, end);
}
if (cmd == "clear-cookies") {
- return {0, clearCookies()};
+ clearCookies();
+ return {0, ""};
}
if (cmd == "dump-cookies") {
return doDumpToFile(socket, pleaseDumpCookiesMap, cmd, false);