2018-07-09 17:32:11 +00:00
|
|
|
#ifndef LLARP_PATHBUILDER_HPP_
|
|
|
|
#define LLARP_PATHBUILDER_HPP_
|
2018-08-30 18:48:43 +00:00
|
|
|
|
2018-07-09 17:32:11 +00:00
|
|
|
#include <llarp/pathset.hpp>
|
2018-06-18 22:03:50 +00:00
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
namespace llarp
|
2018-06-18 22:03:50 +00:00
|
|
|
{
|
2018-08-30 18:48:43 +00:00
|
|
|
namespace path
|
|
|
|
{
|
2018-09-26 13:04:25 +00:00
|
|
|
// milliseconds waiting between builds on a path
|
2018-10-04 16:05:07 +00:00
|
|
|
constexpr llarp_time_t MIN_PATH_BUILD_INTERVAL = 10 * 1000;
|
2018-09-26 13:04:25 +00:00
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
struct Builder : public PathSet
|
|
|
|
{
|
|
|
|
struct llarp_router* router;
|
|
|
|
struct llarp_dht_context* dht;
|
|
|
|
llarp::SecretKey enckey;
|
|
|
|
size_t numHops;
|
2018-09-26 13:04:25 +00:00
|
|
|
llarp_time_t lastBuild = 0;
|
|
|
|
llarp_time_t buildIntervalLimit = MIN_PATH_BUILD_INTERVAL;
|
2018-08-30 18:48:43 +00:00
|
|
|
/// construct
|
|
|
|
Builder(llarp_router* p_router, struct llarp_dht_context* p_dht,
|
|
|
|
size_t numPaths, size_t numHops);
|
|
|
|
|
|
|
|
virtual ~Builder();
|
|
|
|
|
|
|
|
virtual bool
|
|
|
|
SelectHop(llarp_nodedb* db, const RouterContact& prev, RouterContact& cur,
|
|
|
|
size_t hop);
|
|
|
|
|
|
|
|
virtual bool
|
2018-10-29 16:48:36 +00:00
|
|
|
ShouldBuildMore(llarp_time_t now) const;
|
|
|
|
|
|
|
|
llarp_time_t
|
|
|
|
Now() const;
|
2018-08-30 18:48:43 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
BuildOne();
|
|
|
|
|
2018-09-28 15:46:47 +00:00
|
|
|
void
|
|
|
|
Build(const std::vector< RouterContact >& hops);
|
|
|
|
|
|
|
|
bool
|
|
|
|
SelectHops(llarp_nodedb* db, std::vector< RouterContact >& hops);
|
|
|
|
|
2018-08-30 18:48:43 +00:00
|
|
|
void
|
|
|
|
ManualRebuild(size_t N);
|
|
|
|
|
|
|
|
virtual const byte_t*
|
|
|
|
GetTunnelEncryptionSecretKey() const;
|
2018-09-26 13:04:25 +00:00
|
|
|
|
|
|
|
virtual void
|
|
|
|
HandlePathBuilt(Path* p);
|
|
|
|
|
|
|
|
virtual void
|
|
|
|
HandlePathBuildTimeout(Path* p);
|
2018-08-30 18:48:43 +00:00
|
|
|
};
|
|
|
|
} // namespace path
|
|
|
|
|
|
|
|
} // namespace llarp
|
2018-06-18 22:03:50 +00:00
|
|
|
#endif
|