2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2019-06-26 21:39:29 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/util/types.hpp>
|
|
|
|
#include <llarp/router_id.hpp>
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <set>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
struct RouterContact;
|
|
|
|
|
|
|
|
enum class RCRequestResult
|
|
|
|
{
|
|
|
|
Success,
|
|
|
|
InvalidRouter,
|
|
|
|
RouterNotFound,
|
|
|
|
BadRC
|
|
|
|
};
|
|
|
|
|
2020-04-07 18:38:56 +00:00
|
|
|
using RCRequestCallback =
|
|
|
|
std::function<void(const RouterID&, const RouterContact* const, const RCRequestResult)>;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
struct I_RCLookupHandler
|
|
|
|
{
|
|
|
|
virtual ~I_RCLookupHandler() = default;
|
|
|
|
|
|
|
|
virtual void
|
2020-04-07 18:38:56 +00:00
|
|
|
AddValidRouter(const RouterID& router) = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual void
|
2020-04-07 18:38:56 +00:00
|
|
|
RemoveValidRouter(const RouterID& router) = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual void
|
2021-06-07 14:57:33 +00:00
|
|
|
SetRouterWhitelist(
|
|
|
|
const std::vector<RouterID>& whitelist, const std::vector<RouterID>& greylist) = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual void
|
2020-04-07 18:38:56 +00:00
|
|
|
GetRC(const RouterID& router, RCRequestCallback callback, bool forceLookup = false) = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual bool
|
2021-06-07 14:57:33 +00:00
|
|
|
PathIsAllowed(const RouterID& remote) const = 0;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
SessionIsAllowed(const RouterID& remote) const = 0;
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
IsGreylisted(const RouterID& remote) const = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual bool
|
2020-04-07 18:38:56 +00:00
|
|
|
CheckRC(const RouterContact& rc) const = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual bool
|
2020-04-07 18:38:56 +00:00
|
|
|
GetRandomWhitelistRouter(RouterID& router) const = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
CheckRenegotiateValid(RouterContact newrc, RouterContact oldrc) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
PeriodicUpdate(llarp_time_t now) = 0;
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
ExploreNetwork() = 0;
|
2019-09-03 15:56:56 +00:00
|
|
|
|
|
|
|
virtual size_t
|
|
|
|
NumberOfStrictConnectRouters() const = 0;
|
2021-05-11 13:10:16 +00:00
|
|
|
|
|
|
|
virtual bool
|
|
|
|
HaveReceivedWhitelist() const = 0;
|
2019-06-26 21:39:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace llarp
|