mirror of https://github.com/getdnsapi/getdns.git
--without-libunbound option to configure
This commit is contained in:
parent
972ebf55d0
commit
6350b4fad4
24
configure.ac
24
configure.ac
|
@ -259,6 +259,7 @@ else
|
|||
fi
|
||||
fi
|
||||
|
||||
my_with_libunbound=1
|
||||
# find libunbound
|
||||
AC_ARG_WITH(libunbound, AS_HELP_STRING([--with-libunbound=pathname],
|
||||
[path to libunbound (default: search /usr/local ..)]),
|
||||
|
@ -276,6 +277,9 @@ else
|
|||
if test x_$withval != x_no; then
|
||||
CFLAGS="$CFLAGS -I$withval/include"
|
||||
LDFLAGS="$LDFLAGS -L$withval/lib"
|
||||
else
|
||||
AC_DEFINE_UNQUOTED([DISABLE_RESOLUTION_RECURSING], [1], [Define this to disable recursing resolution type.])
|
||||
my_with_libunbound=0
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -289,21 +293,17 @@ AC_CHECK_LIB([idn], [idna_to_ascii_8z], [], [found_all_libs=0])
|
|||
AC_CHECK_MEMBER([struct ldns_struct_dnssec_zone.hashed_names],
|
||||
[AC_DEFINE_UNQUOTED([LDNS_DNSSEC_ZONE_HASHED_NAMES], [1], [When defined ldns_dnssec_zone contained the hashed_names member.])], [], [[#include <ldns/ldns.h>]])
|
||||
|
||||
if test $my_with_libunbound == 1
|
||||
then
|
||||
AC_MSG_NOTICE([Checking for dependency libunbound])
|
||||
AC_CHECK_LIB([unbound], [ub_fd], [], [found_all_libs=0])
|
||||
fi
|
||||
|
||||
if test $found_all_libs == 0
|
||||
then
|
||||
AC_MSG_ERROR([One more dependencies is missing])
|
||||
fi
|
||||
|
||||
# break out libunbound from other libraries since we are currently using a
|
||||
# patch to the sources
|
||||
found_libunbound=1
|
||||
AC_MSG_NOTICE([Checking for dependency libunbound])
|
||||
AC_CHECK_LIB([unbound], [ub_fd], [], [found_libunbound=0])
|
||||
if test $found_libunbound == 0
|
||||
then
|
||||
AC_MSG_ERROR([libunbound is missing.])
|
||||
fi
|
||||
|
||||
AC_PATH_PROG([DOXYGEN], [doxygen])
|
||||
if test -z "$DOXYGEN";
|
||||
then AC_MSG_WARN([doxygen not found, continuing without])
|
||||
|
@ -830,6 +830,10 @@ unsigned char *SHA512(void* data, unsigned int data_len, unsigned char *digest);
|
|||
#ifdef HAVE_BSD_STRING_H
|
||||
#include <bsd/string.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
#include <unbound.h>
|
||||
#endif
|
||||
])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
|
|
|
@ -48,7 +48,7 @@ srcdir = @srcdir@
|
|||
LIBTOOL = ../libtool
|
||||
|
||||
CC=@CC@
|
||||
CFLAGS=-I$(srcdir) -I. @CFLAGS@
|
||||
CFLAGS=-I$(srcdir) -I. @CFLAGS@ @CPPFLAGS@
|
||||
LDFLAGS=@LDFLAGS@ @LIBS@
|
||||
|
||||
EXTENSION_LIBEVENT_LIB=@EXTENSION_LIBEVENT_LIB@
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#include <stdlib.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/time.h>
|
||||
#include <unbound.h>
|
||||
#include <assert.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
|
@ -103,6 +102,7 @@ static void cancel_dns_req(getdns_dns_req *);
|
|||
static void cancel_outstanding_requests(struct getdns_context*, int);
|
||||
|
||||
/* unbound helpers */
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
static getdns_return_t rebuild_ub_ctx(struct getdns_context* context);
|
||||
static void set_ub_string_opt(struct getdns_context *, char *, char *);
|
||||
static void set_ub_number_opt(struct getdns_context *, char *, uint16_t);
|
||||
|
@ -112,6 +112,7 @@ static void set_ub_limit_outstanding_queries(struct getdns_context*,
|
|||
static void set_ub_dnssec_allowed_skew(struct getdns_context*, uint32_t);
|
||||
static void set_ub_edns_maximum_udp_payload_size(struct getdns_context*,
|
||||
int);
|
||||
#endif
|
||||
|
||||
/* Stuff to make it compile pedantically */
|
||||
#define RETURN_IF_NULL(ptr, code) if(ptr == NULL) return code;
|
||||
|
@ -909,9 +910,11 @@ getdns_context_create_with_extended_memory_functions(
|
|||
* don't know that till later so we will have to do this every time. */
|
||||
|
||||
SSL_library_init();
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
result->unbound_ctx = NULL;
|
||||
if ((r = rebuild_ub_ctx(result)))
|
||||
goto error;
|
||||
#endif
|
||||
|
||||
create_local_hosts(result);
|
||||
|
||||
|
@ -985,8 +988,10 @@ getdns_context_destroy(struct getdns_context *context)
|
|||
*/
|
||||
priv_getdns_upstreams_dereference(context->upstreams);
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
if (context->unbound_ctx)
|
||||
ub_ctx_delete(context->unbound_ctx);
|
||||
#endif
|
||||
|
||||
context->processing = 0;
|
||||
context->extension->vmt->cleanup(context->extension);
|
||||
|
@ -1059,6 +1064,7 @@ getdns_context_get_update_callback(getdns_context *context, void **userarg,
|
|||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
/*
|
||||
* Helpers to set options on the unbound ctx
|
||||
*/
|
||||
|
@ -1149,6 +1155,11 @@ rebuild_ub_ctx(struct getdns_context* context) {
|
|||
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
#else
|
||||
#define set_ub_string_opt(ctx, opt, value) do {} while (0)
|
||||
#define set_ub_number_opt(ctx, opt, value) do {} while (0)
|
||||
#define getdns_context_request_count_changed(context) do {} while (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Helper to dispatch the updated callback
|
||||
|
@ -1930,11 +1941,13 @@ cancel_dns_req(getdns_dns_req *req)
|
|||
getdns_network_req *netreq, **netreq_p;
|
||||
|
||||
for (netreq_p = req->netreqs; (netreq = *netreq_p); netreq_p++)
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
if (netreq->unbound_id != -1) {
|
||||
ub_cancel(req->context->unbound_ctx,
|
||||
netreq->unbound_id);
|
||||
netreq->unbound_id = -1;
|
||||
} else
|
||||
#endif
|
||||
priv_getdns_cancel_stub_request(netreq);
|
||||
|
||||
req->canceled = 1;
|
||||
|
@ -2113,8 +2126,10 @@ ub_setup_stub(struct ub_ctx *ctx, getdns_context *context)
|
|||
static getdns_return_t
|
||||
priv_getdns_ns_dns_setup(struct getdns_context *context)
|
||||
{
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
priv_getdns_rr_iter rr_spc, *rr;
|
||||
char ta_str[8192];
|
||||
#endif
|
||||
assert(context);
|
||||
|
||||
switch (context->resolution_type) {
|
||||
|
@ -2128,6 +2143,7 @@ priv_getdns_ns_dns_setup(struct getdns_context *context)
|
|||
#endif
|
||||
|
||||
case GETDNS_RESOLUTION_RECURSING:
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
/* TODO: use the root servers via root hints file */
|
||||
(void) ub_ctx_set_fwd(context->unbound_ctx, NULL);
|
||||
if (!context->unbound_ta_set && context->trust_anchors) {
|
||||
|
@ -2144,6 +2160,9 @@ priv_getdns_ns_dns_setup(struct getdns_context *context)
|
|||
context->unbound_ta_set = 1;
|
||||
}
|
||||
return GETDNS_RETURN_GOOD;
|
||||
#else
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
#endif
|
||||
}
|
||||
return GETDNS_RETURN_BAD_CONTEXT;
|
||||
}
|
||||
|
@ -2347,6 +2366,7 @@ getdns_context_process_async(struct getdns_context* context)
|
|||
{
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
context->processing = 1;
|
||||
if (ub_poll(context->unbound_ctx) && ub_process(context->unbound_ctx)){
|
||||
/* need an async return code? */
|
||||
|
@ -2354,6 +2374,7 @@ getdns_context_process_async(struct getdns_context* context)
|
|||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
}
|
||||
context->processing = 0;
|
||||
#endif
|
||||
context->extension->vmt->run_once(context->extension, 0);
|
||||
|
||||
return GETDNS_RETURN_GOOD;
|
||||
|
@ -2554,15 +2575,19 @@ getdns_context_set_return_dnssec_status(getdns_context* context, int enabled) {
|
|||
getdns_return_t
|
||||
getdns_context_set_use_threads(getdns_context* context, int use_threads) {
|
||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||
int r = 0;
|
||||
if (context->resolution_type_set != 0) {
|
||||
/* already setup */
|
||||
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
int r = 0;
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
if (use_threads)
|
||||
r = ub_ctx_async(context->unbound_ctx, 1);
|
||||
else
|
||||
r = ub_ctx_async(context->unbound_ctx, 0);
|
||||
#else
|
||||
(void)use_threads;
|
||||
#endif
|
||||
return r == 0 ? GETDNS_RETURN_GOOD : GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -166,9 +166,11 @@ struct getdns_context {
|
|||
struct mem_funcs mf;
|
||||
struct mem_funcs my_mf;
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
/* The underlying contexts that do the real work */
|
||||
struct ub_ctx *unbound_ctx;
|
||||
int unbound_ta_set;
|
||||
#endif
|
||||
|
||||
/* A tree to hold local host information*/
|
||||
getdns_rbtree_t local_hosts;
|
||||
|
@ -187,7 +189,10 @@ struct getdns_context {
|
|||
|
||||
/* Event loop extension. */
|
||||
getdns_eventloop *extension;
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
getdns_eventloop_event ub_event;
|
||||
#endif
|
||||
|
||||
/* The default extension */
|
||||
getdns_mini_event mini_event;
|
||||
|
|
|
@ -191,7 +191,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <unbound.h>
|
||||
#include <ldns/ldns.h>
|
||||
#include "getdns/getdns.h"
|
||||
#include "config.h"
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unbound.h>
|
||||
#include "config.h"
|
||||
#include "gldns/wire2str.h"
|
||||
#include "context.h"
|
||||
|
@ -71,13 +70,6 @@ void priv_getdns_call_user_callback(getdns_dns_req *dns_req,
|
|||
response, user_arg, trans_id);
|
||||
}
|
||||
|
||||
/* cleanup and send an error to the user callback */
|
||||
static void
|
||||
handle_network_request_error(getdns_network_req * netreq, int err)
|
||||
{
|
||||
priv_getdns_call_user_callback(netreq->owner, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
priv_getdns_check_dns_req_complete(getdns_dns_req *dns_req)
|
||||
{
|
||||
|
@ -108,6 +100,7 @@ priv_getdns_check_dns_req_complete(getdns_dns_req *dns_req)
|
|||
dns_req, create_getdns_response(dns_req));
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
static void
|
||||
ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
|
||||
{
|
||||
|
@ -116,13 +109,13 @@ ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
|
|||
|
||||
netreq->state = NET_REQ_FINISHED;
|
||||
if (err != 0) {
|
||||
handle_network_request_error(netreq, err);
|
||||
priv_getdns_call_user_callback(dns_req, NULL);
|
||||
return;
|
||||
}
|
||||
/* parse */
|
||||
if (getdns_apply_network_result(netreq, ub_res)) {
|
||||
ub_resolve_free(ub_res);
|
||||
handle_network_request_error(netreq, err);
|
||||
priv_getdns_call_user_callback(dns_req, NULL);
|
||||
return;
|
||||
}
|
||||
ub_resolve_free(ub_res);
|
||||
|
@ -130,6 +123,7 @@ ub_resolve_callback(void* arg, int err, struct ub_result* ub_res)
|
|||
priv_getdns_check_dns_req_complete(dns_req);
|
||||
|
||||
} /* ub_resolve_callback */
|
||||
#endif
|
||||
|
||||
|
||||
static getdns_return_t
|
||||
|
@ -164,10 +158,14 @@ submit_network_request(getdns_network_req *netreq)
|
|||
(void) gldns_wire2str_dname_buf(dns_req->name,
|
||||
dns_req->name_len, name, sizeof(name));
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
return ub_resolve_async(dns_req->context->unbound_ctx,
|
||||
name, netreq->request_type, netreq->request_class,
|
||||
netreq, ub_resolve_callback, &(netreq->unbound_id)) ?
|
||||
GETDNS_RETURN_GENERIC_ERROR : GETDNS_RETURN_GOOD;
|
||||
#else
|
||||
return GETDNS_RETURN_GENERIC_ERROR;
|
||||
#endif
|
||||
}
|
||||
/* Submit with stub resolver */
|
||||
return priv_getdns_submit_stub_request(netreq);
|
||||
|
|
13
src/sync.c
13
src/sync.c
|
@ -34,7 +34,6 @@
|
|||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <unbound.h>
|
||||
#include "getdns/getdns.h"
|
||||
#include "config.h"
|
||||
#include "context.h"
|
||||
|
@ -48,7 +47,9 @@
|
|||
|
||||
typedef struct getdns_sync_loop {
|
||||
getdns_mini_event loop;
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
getdns_eventloop_event ub_event;
|
||||
#endif
|
||||
getdns_context *context;
|
||||
int to_run;
|
||||
getdns_dict *response;
|
||||
|
@ -57,8 +58,10 @@ typedef struct getdns_sync_loop {
|
|||
static getdns_return_t
|
||||
getdns_sync_loop_init(getdns_context *context, getdns_sync_loop *loop)
|
||||
{
|
||||
getdns_return_t r;
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
getdns_eventloop *ext = &loop->loop.loop;
|
||||
#endif
|
||||
getdns_return_t r;
|
||||
|
||||
loop->response = NULL;
|
||||
loop->to_run = 1;
|
||||
|
@ -67,6 +70,7 @@ getdns_sync_loop_init(getdns_context *context, getdns_sync_loop *loop)
|
|||
if ((r = getdns_mini_event_init(context, &loop->loop)))
|
||||
return r;
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
loop->ub_event.userarg = loop->context;
|
||||
loop->ub_event.read_cb = priv_getdns_context_ub_read_cb;
|
||||
loop->ub_event.write_cb = NULL;
|
||||
|
@ -75,6 +79,9 @@ getdns_sync_loop_init(getdns_context *context, getdns_sync_loop *loop)
|
|||
|
||||
return ext->vmt->schedule(ext, ub_fd(context->unbound_ctx),
|
||||
TIMEOUT_FOREVER, &loop->ub_event);
|
||||
#else
|
||||
return GETDNS_RETURN_GOOD;
|
||||
#endif
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -82,7 +89,9 @@ getdns_sync_loop_cleanup(getdns_sync_loop *loop)
|
|||
{
|
||||
getdns_eventloop *ext = &loop->loop.loop;
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
ext->vmt->clear(ext, &loop->ub_event);
|
||||
#endif
|
||||
ext->vmt->cleanup(ext);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <unbound.h>
|
||||
#include "getdns/getdns.h"
|
||||
#include "dict.h"
|
||||
#include "list.h"
|
||||
|
@ -846,6 +845,7 @@ priv_getdns_validate_extensions(struct getdns_dict * extensions)
|
|||
return GETDNS_RETURN_GOOD;
|
||||
} /* priv_getdns_validate_extensions */
|
||||
|
||||
#ifdef HAVE_LIBUNBOUND
|
||||
getdns_return_t
|
||||
getdns_apply_network_result(getdns_network_req* netreq,
|
||||
struct ub_result* ub_res)
|
||||
|
@ -908,6 +908,7 @@ getdns_apply_network_result(getdns_network_req* netreq,
|
|||
|
||||
return GETDNS_RETURN_GOOD;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
getdns_return_t
|
||||
|
|
Loading…
Reference in New Issue