mirror of https://github.com/oxen-io/lokinet
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
6 years ago
|
#ifndef LLARP_EXIT_CONTEXT_HPP
|
||
|
#define LLARP_EXIT_CONTEXT_HPP
|
||
6 years ago
|
#include <exit/policy.hpp>
|
||
6 years ago
|
#include <string>
|
||
|
#include <unordered_map>
|
||
|
#include <llarp/handlers/exit.hpp>
|
||
|
|
||
|
namespace llarp
|
||
|
{
|
||
|
namespace exit
|
||
|
{
|
||
|
/// owner of all the exit endpoints
|
||
|
struct Context
|
||
|
{
|
||
|
using Config_t = std::unordered_multimap< std::string, std::string >;
|
||
|
|
||
6 years ago
|
Context(llarp::Router *r);
|
||
6 years ago
|
~Context();
|
||
|
|
||
|
void
|
||
|
Tick(llarp_time_t now);
|
||
|
|
||
6 years ago
|
void
|
||
|
ClearAllEndpoints();
|
||
|
|
||
6 years ago
|
bool
|
||
|
AddExitEndpoint(const std::string &name, const Config_t &config);
|
||
|
|
||
6 years ago
|
bool
|
||
|
ObtainNewExit(const llarp::PubKey &remote, const llarp::PathID_t &path,
|
||
|
bool permitInternet);
|
||
|
|
||
|
llarp::exit::Endpoint *
|
||
|
FindEndpointForPath(const llarp::PathID_t &path) const;
|
||
|
|
||
6 years ago
|
/// calculate (pk, tx, rx) for all exit traffic
|
||
|
using TrafficStats =
|
||
|
std::unordered_map< PubKey, std::pair< uint64_t, uint64_t >,
|
||
|
PubKey::Hash >;
|
||
|
|
||
|
void
|
||
|
CalculateExitTraffic(TrafficStats &stats);
|
||
|
|
||
6 years ago
|
private:
|
||
6 years ago
|
llarp::Router *m_Router;
|
||
6 years ago
|
std::unordered_map< std::string,
|
||
|
std::unique_ptr< llarp::handlers::ExitEndpoint > >
|
||
|
m_Exits;
|
||
|
};
|
||
|
} // namespace exit
|
||
|
} // namespace llarp
|
||
|
|
||
6 years ago
|
#endif
|