2018-11-12 16:43:40 +00:00
|
|
|
#ifndef LLARP_EXIT_CONTEXT_HPP
|
|
|
|
#define LLARP_EXIT_CONTEXT_HPP
|
2018-12-12 01:06:46 +00:00
|
|
|
#include <exit/policy.hpp>
|
2018-12-12 01:12:59 +00:00
|
|
|
#include <handlers/exit.hpp>
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
#include <string>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
namespace exit
|
|
|
|
{
|
|
|
|
/// owner of all the exit endpoints
|
2019-04-19 15:10:26 +00:00
|
|
|
struct Context
|
2018-11-12 16:43:40 +00:00
|
|
|
{
|
|
|
|
using Config_t = std::unordered_multimap< std::string, std::string >;
|
|
|
|
|
2019-02-11 19:45:42 +00:00
|
|
|
Context(AbstractRouter *r);
|
2018-11-12 16:43:40 +00:00
|
|
|
~Context();
|
|
|
|
|
|
|
|
void
|
|
|
|
Tick(llarp_time_t now);
|
|
|
|
|
2018-11-15 21:47:05 +00:00
|
|
|
void
|
|
|
|
ClearAllEndpoints();
|
|
|
|
|
2019-02-11 17:14:43 +00:00
|
|
|
util::StatusObject
|
2019-04-19 15:10:26 +00:00
|
|
|
ExtractStatus() const;
|
2019-02-08 19:43:25 +00:00
|
|
|
|
2018-12-24 16:09:05 +00:00
|
|
|
/// send close to all exit sessions and remove all sessions
|
|
|
|
void
|
|
|
|
Stop();
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
bool
|
|
|
|
AddExitEndpoint(const std::string &name, const Config_t &config);
|
|
|
|
|
2018-11-14 12:23:08 +00:00
|
|
|
bool
|
2019-07-02 21:28:28 +00:00
|
|
|
ObtainNewExit(const PubKey &remote, const PathID_t &path,
|
2018-11-14 12:23:08 +00:00
|
|
|
bool permitInternet);
|
|
|
|
|
2019-07-02 21:28:28 +00:00
|
|
|
exit::Endpoint *
|
|
|
|
FindEndpointForPath(const PathID_t &path) const;
|
2018-11-14 12:23:08 +00:00
|
|
|
|
2018-11-14 18:02:27 +00:00
|
|
|
/// 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);
|
|
|
|
|
2018-11-12 16:43:40 +00:00
|
|
|
private:
|
2019-02-11 19:45:42 +00:00
|
|
|
AbstractRouter *m_Router;
|
2018-11-12 16:43:40 +00:00
|
|
|
std::unordered_map< std::string,
|
2019-07-02 21:28:28 +00:00
|
|
|
std::shared_ptr< handlers::ExitEndpoint > >
|
2018-11-12 16:43:40 +00:00
|
|
|
m_Exits;
|
2019-07-02 21:28:28 +00:00
|
|
|
std::list< std::shared_ptr< handlers::ExitEndpoint > > m_Closed;
|
2018-11-12 16:43:40 +00:00
|
|
|
};
|
|
|
|
} // namespace exit
|
|
|
|
} // namespace llarp
|
|
|
|
|
2018-12-10 16:26:46 +00:00
|
|
|
#endif
|