llarp/util/geoip.hpp
Namespaces
| Name |
|---|
| llarp [crypto.hpp] |
| llarp::util |
Classes
| Name | |
|---|---|
| class | llarp::util::GeoIPHelper GeoIP helper class. |
Source code
#pragma once
#include <llarp/net/sock_addr.hpp>
#include <llarp/util/thread/threading.hpp>
#include <unordered_set>
#include <unordered_map>
namespace llarp::util
{
class GeoIPHelper
{
struct Pimpl;
// a cached lookup.
struct CacheEntry
{
std::string country_code;
std::chrono::time_point<std::chrono::steady_clock> expires_at;
};
NullMutex m_Access;
std::unordered_map<SockAddr, CacheEntry> m_LookupCache;
std::shared_ptr<Pimpl> m_Impl;
public:
GeoIPHelper();
~GeoIPHelper();
bool
address_in_country_code_set(
const SockAddr& addr, const std::unordered_set<std::string>& country_codes);
void
maybe_decay_cache();
};
std::shared_ptr<GeoIPHelper>
GeoIPHelperInstance();
} // namespace llarp::util
Updated on 2026-01-10 at 22:49:46 +0000