mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
74362149eb
we want to be able to have multiple locally bound dns sockets in lokinet so i restructured most of the dns subsystem in order to make this easier. specifically, we have a new structure to dns subsystem: * dns::QueryJob_Base base type for holding a dns query and response with virtual methods in charge of sending a reply to whoever requested. * dns::PacketSource_Base base type for reading and writing dns messages to and from wherever they came from * dns::Resolver_Base base type for filtering and handling of dns messages asynchronously. * dns::Server contextualized per endpoint dns object, responsible for all dns related isms. this change hides all impelementation details of all of the dns components. adds some more helper functions for parsing dns and dealing with OwnedBuffer. overall dns becomes less of a pain with this new structure. probably.
33 lines
764 B
C++
33 lines
764 B
C++
#pragma once
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace llarp
|
|
{
|
|
/// type for comparing smart pointer's managed values
|
|
template <typename Ptr_t, typename Compare = std::less<>>
|
|
struct ComparePtr
|
|
{
|
|
bool
|
|
operator()(const Ptr_t& left, const Ptr_t& right) const
|
|
{
|
|
if (left && right)
|
|
return Compare()(*left, *right);
|
|
|
|
return Compare()(left, right);
|
|
}
|
|
};
|
|
|
|
/// type for comparing weak_ptr by value
|
|
template <typename Type_t, typename Compare = std::less<>>
|
|
struct CompareWeakPtr
|
|
{
|
|
bool
|
|
operator()(const std::weak_ptr<Type_t>& left, const std::weak_ptr<Type_t>& right) const
|
|
{
|
|
return ComparePtr<std::shared_ptr<Type_t>, Compare>{}(left.lock(), right.lock());
|
|
}
|
|
};
|
|
|
|
} // namespace llarp
|