mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
46ad8d4058
- includes are now sorted in consistent, logical order; first step in an attempt to fix the tomfoolery (no relation to Tom) brought in by include-what-you-use - shuffled around some cmake linking to simplify dependency graph - superfluous files removed
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#pragma once
|
|
#include "policy.hpp"
|
|
|
|
#include <llarp/handlers/exit.hpp>
|
|
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace llarp::exit
|
|
{
|
|
/// owner of all the exit endpoints
|
|
struct Context
|
|
{
|
|
Context(Router* r);
|
|
~Context();
|
|
|
|
void
|
|
Tick(llarp_time_t now);
|
|
|
|
void
|
|
ClearAllEndpoints();
|
|
|
|
util::StatusObject
|
|
ExtractStatus() const;
|
|
|
|
/// send close to all exit sessions and remove all sessions
|
|
void
|
|
Stop();
|
|
|
|
void
|
|
AddExitEndpoint(
|
|
const std::string& name, const NetworkConfig& networkConfig, const DnsConfig& dnsConfig);
|
|
|
|
bool
|
|
ObtainNewExit(const PubKey& remote, const PathID_t& path, bool permitInternet);
|
|
|
|
exit::Endpoint*
|
|
FindEndpointForPath(const PathID_t& path) const;
|
|
|
|
/// calculate (pk, tx, rx) for all exit traffic
|
|
using TrafficStats = std::unordered_map<PubKey, std::pair<uint64_t, uint64_t>>;
|
|
|
|
void
|
|
CalculateExitTraffic(TrafficStats& stats);
|
|
|
|
std::shared_ptr<handlers::ExitEndpoint>
|
|
GetExitEndpoint(std::string name) const;
|
|
|
|
private:
|
|
Router* router;
|
|
std::unordered_map<std::string, std::shared_ptr<handlers::ExitEndpoint>> m_Exits;
|
|
std::list<std::shared_ptr<handlers::ExitEndpoint>> m_Closed;
|
|
};
|
|
} // namespace llarp::exit
|