From 31595d209de4c1e7796f9c2e46b205e6de64d452 Mon Sep 17 00:00:00 2001 From: Ryan Tharp Date: Sat, 22 Sep 2018 03:22:18 -0700 Subject: [PATCH] move logic into client --- llarp/dnsd.cpp | 13 +++++++------ llarp/dnsd.hpp | 10 ++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/llarp/dnsd.cpp b/llarp/dnsd.cpp index 1e1f3c86e..42f532842 100644 --- a/llarp/dnsd.cpp +++ b/llarp/dnsd.cpp @@ -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) { @@ -400,12 +400,13 @@ 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->intercept = nullptr; // set default intercepter + dnsd->tracker = &dns_udp_tracker; // register global tracker with context + // 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; diff --git a/llarp/dnsd.hpp b/llarp/dnsd.hpp index 928387c77..8b777c6c8 100644 --- a/llarp/dnsd.hpp +++ b/llarp/dnsd.hpp @@ -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);