2018-08-08 12:41:09 +00:00
|
|
|
#ifndef LIBLLARP_DNSIPTRACKER_HPP
|
|
|
|
#define LIBLLARP_DNSIPTRACKER_HPP
|
|
|
|
|
|
|
|
#include <llarp/net.hpp>
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2018-09-20 12:37:19 +00:00
|
|
|
#include <llarp/service/address.hpp>
|
2018-09-22 10:24:32 +00:00
|
|
|
#include "dns_dotlokilookup.hpp"
|
2018-08-08 12:41:09 +00:00
|
|
|
|
|
|
|
// either a request or response?
|
2018-09-20 12:37:19 +00:00
|
|
|
// neither, it's a result set row
|
2018-08-08 12:41:09 +00:00
|
|
|
struct dns_pointer
|
|
|
|
{
|
2018-09-29 10:25:50 +00:00
|
|
|
// FIXME change to llarp::Addr
|
2018-08-08 12:41:09 +00:00
|
|
|
struct sockaddr *hostResult;
|
2018-09-20 12:37:19 +00:00
|
|
|
llarp::service::Address b32addr;
|
2018-09-29 10:25:50 +00:00
|
|
|
// we could store the timeout at which we expect it to be available
|
|
|
|
// or a list of pending requests for it
|
2018-08-08 12:41:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ip_range
|
|
|
|
{
|
|
|
|
uint8_t octet2;
|
|
|
|
uint8_t octet3;
|
|
|
|
// FIXME: we're not consecutive
|
|
|
|
uint8_t left;
|
2018-09-25 13:20:39 +00:00
|
|
|
std::unordered_map< uint8_t, dns_pointer * > used;
|
2018-08-08 12:41:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct dns_iptracker
|
|
|
|
{
|
|
|
|
struct privatesInUse interfaces;
|
|
|
|
struct privatesInUse used_privates;
|
2018-09-29 10:25:50 +00:00
|
|
|
std::vector< std::unique_ptr< ip_range > > used_ten_ips;
|
|
|
|
std::vector< std::unique_ptr< ip_range > > used_seven_ips;
|
|
|
|
std::vector< std::unique_ptr< ip_range > > used_nine_ips;
|
2018-08-08 12:41:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void
|
|
|
|
dns_iptracker_init();
|
|
|
|
|
2018-09-22 10:24:32 +00:00
|
|
|
bool
|
|
|
|
dns_iptracker_setup_dotLokiLookup(dotLokiLookup *dll, llarp::Addr tunGatewayIp);
|
|
|
|
|
2018-09-20 12:37:19 +00:00
|
|
|
bool
|
|
|
|
dns_iptracker_setup(llarp::Addr tunGatewayIp);
|
|
|
|
|
2018-08-08 12:41:09 +00:00
|
|
|
struct dns_pointer *
|
|
|
|
dns_iptracker_get_free();
|
|
|
|
|
2018-09-22 10:24:32 +00:00
|
|
|
struct dns_pointer *
|
|
|
|
dns_iptracker_get_free(dns_iptracker *iptracker);
|
|
|
|
|
2018-08-08 12:41:09 +00:00
|
|
|
#endif
|