move logic into client

This commit is contained in:
Ryan Tharp 2018-09-22 03:22:18 -07:00
parent e53e093e17
commit 31595d209d
2 changed files with 11 additions and 12 deletions

View File

@ -384,8 +384,8 @@ raw_handle_recvfrom(int *sockfd, const struct sockaddr *saddr, const void *buf,
}
bool
llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_ev_loop *netloop,
struct llarp_logic *logic, const char *dnsd_ifname,
llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_logic *logic,
struct llarp_ev_loop *netloop, const char *dnsd_ifname,
uint16_t dnsd_port, const char *dnsc_hostname,
uint16_t dnsc_port)
{
@ -401,11 +401,12 @@ llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_ev_loop *netloop,
dns_udp_tracker.dnsd = dnsd;
dnsd->tracker = &dns_udp_tracker; // register global tracker with context
dnsd->logic = logic; // set logic worker for timers
// dnsd->logic = logic; // set logic worker for timers
dnsd->intercept = nullptr; // set default intercepter
// configure dns client
if(!llarp_dnsc_init(&dnsd->client, &dnsd->udp, dnsc_hostname, dnsc_port))
if(!llarp_dnsc_init(&dnsd->client, logic, &dnsd->udp, dnsc_hostname,
dnsc_port))
{
llarp::LogError("Couldnt init dns client");
return false;

View File

@ -53,13 +53,11 @@ struct dnsd_context
{
/// DNS daemon socket to listen on
struct llarp_udp_io udp;
/// for timers (MAYBEFIXME? maybe we decouple this, yes pls have a generic passed in)
struct llarp_logic *logic;
/// tracker
/// udp tracker
struct dns_tracker *tracker;
/// upstream DNS client context to use
dnsc_context client;
/// custom data for intercept query hook
/// custom data for intercept query hook (used for configuration of hook)
void *user;
/// hook function for intercepting dns requests
intercept_query_hook intercept;
@ -83,8 +81,8 @@ writesend_dnss_response(struct sockaddr *hostRes, const struct sockaddr *from,
/// initialize dns subsystem and bind socket
/// returns true on bind success otherwise returns false
bool
llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_ev_loop *netloop,
struct llarp_logic *logic, const char *dnsd_ifname,
llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_logic *logic,
struct llarp_ev_loop *netloop, const char *dnsd_ifname,
uint16_t dnsd_port, const char *dnsc_hostname,
uint16_t dnsc_port);