2021-03-09 22:24:35 +00:00
|
|
|
#pragma once
|
2018-05-25 09:17:08 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/crypto/crypto.hpp>
|
|
|
|
#include <llarp/router_contact.hpp>
|
|
|
|
#include <llarp/util/buffer.hpp>
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2018-05-25 09:17:08 +00:00
|
|
|
/**
|
|
|
|
* dht.h
|
|
|
|
*
|
|
|
|
* DHT functions
|
|
|
|
*/
|
|
|
|
|
2018-02-01 17:07:01 +00:00
|
|
|
struct llarp_dht_context;
|
2018-02-01 17:06:49 +00:00
|
|
|
|
2018-12-13 16:14:44 +00:00
|
|
|
namespace llarp
|
|
|
|
{
|
2019-02-11 19:45:42 +00:00
|
|
|
struct AbstractRouter;
|
2018-12-13 16:14:44 +00:00
|
|
|
}
|
2018-12-10 16:26:46 +00:00
|
|
|
|
2018-05-25 09:17:08 +00:00
|
|
|
/// allocator
|
2018-05-22 15:54:19 +00:00
|
|
|
struct llarp_dht_context*
|
2019-02-11 19:45:42 +00:00
|
|
|
llarp_dht_context_new(llarp::AbstractRouter* parent);
|
2018-05-25 09:17:08 +00:00
|
|
|
|
|
|
|
/// deallocator
|
2018-05-22 15:54:19 +00:00
|
|
|
void
|
|
|
|
llarp_dht_context_free(struct llarp_dht_context* dht);
|
2018-02-01 17:06:49 +00:00
|
|
|
|
2018-06-01 21:35:17 +00:00
|
|
|
/// start dht context with our location in keyspace
|
2018-06-01 14:08:54 +00:00
|
|
|
void
|
2018-06-01 21:35:17 +00:00
|
|
|
llarp_dht_context_start(struct llarp_dht_context* ctx, const byte_t* key);
|
2018-06-01 14:08:54 +00:00
|
|
|
|
2018-09-19 12:22:34 +00:00
|
|
|
// remove this? dns needs it atm
|
2018-06-01 21:35:17 +00:00
|
|
|
struct llarp_router_lookup_job;
|
|
|
|
|
2019-07-30 23:42:13 +00:00
|
|
|
using llarp_router_lookup_handler = void (*)(struct llarp_router_lookup_job*);
|
2018-06-01 21:35:17 +00:00
|
|
|
|
|
|
|
struct llarp_router_lookup_job
|
|
|
|
{
|
2018-06-28 11:33:52 +00:00
|
|
|
/// can be anything but usually a class context for hook
|
2018-06-01 21:35:17 +00:00
|
|
|
void* user;
|
2018-06-18 07:54:50 +00:00
|
|
|
llarp_router_lookup_handler hook;
|
2018-06-01 21:35:17 +00:00
|
|
|
struct llarp_dht_context* dht;
|
2018-09-19 12:22:34 +00:00
|
|
|
llarp::PubKey target;
|
2018-06-01 21:35:17 +00:00
|
|
|
bool found;
|
2018-07-08 13:22:02 +00:00
|
|
|
// make sure you initialize addr and exits
|
2018-09-19 12:22:34 +00:00
|
|
|
llarp::RouterContact result;
|
2018-07-08 13:22:02 +00:00
|
|
|
bool iterative;
|
2018-06-01 21:35:17 +00:00
|
|
|
};
|
2018-09-19 12:22:34 +00:00
|
|
|
// end dns requirement
|
2018-06-01 21:35:17 +00:00
|
|
|
|
2018-06-13 16:32:34 +00:00
|
|
|
/// start allowing dht participation on a context
|
|
|
|
void
|
|
|
|
llarp_dht_allow_transit(struct llarp_dht_context* ctx);
|
|
|
|
|
2018-06-14 14:04:42 +00:00
|
|
|
/// remove router from tracked dht peer list
|
2018-08-17 19:49:58 +00:00
|
|
|
/// internal function do not use
|
2018-06-01 21:35:17 +00:00
|
|
|
void
|
2018-08-17 19:49:58 +00:00
|
|
|
__llarp_dht_remove_peer(struct llarp_dht_context* ctx, const byte_t* id);
|
2018-06-01 21:35:17 +00:00
|
|
|
|
|
|
|
void
|
2020-04-07 18:38:56 +00:00
|
|
|
llarp_dht_lookup_router(struct llarp_dht_context* ctx, struct llarp_router_lookup_job* job);
|