prefetch and expose it

pull/16/head
Ryan Tharp 6 years ago
parent 4df6202c9f
commit ca7d3567a2

@ -103,6 +103,10 @@ extern "C"
bool
main_router_mapAddress(struct llarp_main *ptr, const llarp::service::Address &addr, uint32_t ip);
/// info of possible path usage
bool
main_router_prefetch(struct llarp_main *ptr, const llarp::service::Address &addr);
}
#endif
#endif

@ -27,6 +27,10 @@ namespace llarp
llarp_tun_io *
getRange();
/// hint at possible path usage and trigger building early
bool
Prefetch(const llarp::service::Address &addr);
/// punch a hole open for DNS to add mappings
bool
MapAddress(const llarp::service::Address &addr, uint32_t ip);

@ -451,6 +451,13 @@ main_router_mapAddress(struct llarp_main *ptr, const llarp::service::Address &ad
return endpoint->MapAddress(addr, ip);
}
bool
main_router_prefetch(struct llarp_main *ptr, const llarp::service::Address &addr)
{
auto *endpoint = &ptr->ctx->router->hiddenServiceContext;
return endpoint->Prefetch(addr);
}
llarp_tun_io *
main_router_getRange(struct llarp_main *ptr)
{

@ -1,5 +1,6 @@
#include <llarp/handlers/tun.hpp>
#include <llarp/service/context.hpp>
#include <llarp/service/endpoint.hpp>
namespace llarp
{
@ -57,6 +58,19 @@ namespace llarp
return &tunEndpoint->tunif;
}
bool
Context::Prefetch(const llarp::service::Address &addr)
{
llarp::handlers::TunEndpoint *tunEndpoint = this->getFirstTun();
if (!tunEndpoint)
{
llarp::LogError("No tunnel endpoint found");
return false;
}
//HiddenServiceAddresslookup *lookup = new HiddenServiceEndpoint(tunEndpoint, callback, addr, tunEndpoint->GenTXID());
return tunEndpoint->EnsurePathToService(addr, [](Address addr, void* ctx) {}, 10000);
}
bool
Context::MapAddress(const llarp::service::Address &addr, uint32_t ip)
{

Loading…
Cancel
Save