diff --git a/include/llarp/dnsd.hpp b/include/llarp/dnsd.hpp index df96d513a..be38921dc 100644 --- a/include/llarp/dnsd.hpp +++ b/include/llarp/dnsd.hpp @@ -3,8 +3,8 @@ #include // for sockaadr #include -#include "dns.hpp" // question and dnsc -#include "dnsc.hpp" +#include // question and dnsc +#include // fwd declaration struct dnsd_context; @@ -85,12 +85,14 @@ 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_logic *logic, - struct llarp_ev_loop *netloop, const llarp::Addr &dnsd_sockaddr, +llarp_dnsd_init(struct dnsd_context *const dnsd, + struct llarp_logic *const logic, + struct llarp_ev_loop *const netloop, + const llarp::Addr &dnsd_sockaddr, const llarp::Addr &dnsc_sockaddr); /// shutdowns any events, and deallocates for this context bool -llarp_dnsd_stop(struct dnsd_context *dnsd); +llarp_dnsd_stop(struct dnsd_context *const dnsd); #endif diff --git a/llarp/dnsd.cpp b/llarp/dnsd.cpp index 78fb0e42b..1e476b673 100644 --- a/llarp/dnsd.cpp +++ b/llarp/dnsd.cpp @@ -269,7 +269,7 @@ handle_dnsc_result(dnsc_answer_request *client_request) else { writesend_dnss_response( - client_request->found ? &client_request->result : nullptr, + client_request->found ? client_request->result.getSockAddr() : nullptr, server_request->from, server_request); } llarp_host_resolved(client_request); @@ -319,6 +319,16 @@ handle_recvfrom(const char *buffer, ssize_t nbytes, const struct sockaddr *from, sockaddr *fromCopy = new sockaddr(*from); // make our own sockaddr that won't get cleaned up + if(!request) + { + llarp::LogError("request is not configured"); + return; + } + if(!request->context) + { + llarp::LogError("request context is not configured"); + return; + } if(request->context->intercept) { // llarp::Addr test(*from); @@ -428,8 +438,10 @@ raw_handle_recvfrom(int *sockfd, const struct sockaddr *saddr, const void *buf, } bool -llarp_dnsd_init(struct dnsd_context *dnsd, struct llarp_logic *logic, - struct llarp_ev_loop *netloop, const llarp::Addr &dnsd_sockaddr, +llarp_dnsd_init(struct dnsd_context *const dnsd, + struct llarp_logic *const logic, + struct llarp_ev_loop *const netloop, + const llarp::Addr &dnsd_sockaddr, const llarp::Addr &dnsc_sockaddr) { // struct sockaddr_in bindaddr;