summaryrefslogtreecommitdiff
path: root/sbin/unwind
diff options
context:
space:
mode:
authorFlorian Obser <florian@cvs.openbsd.org>2019-04-01 09:24:16 +0000
committerFlorian Obser <florian@cvs.openbsd.org>2019-04-01 09:24:16 +0000
commit2fc221afa9989fb60a8d0dff8d66b1de40c72b0d (patch)
tree20603172ad47b7a42f593f2e296f6f4d432fe615 /sbin/unwind
parent53c281bfec7188f21987838e3adb7a7a4238e168 (diff)
Reduce code duplication and ensure that a type of resolver and it's
checking counterpart are created the same way.
Diffstat (limited to 'sbin/unwind')
-rw-r--r--sbin/unwind/resolver.c50
1 files changed, 21 insertions, 29 deletions
diff --git a/sbin/unwind/resolver.c b/sbin/unwind/resolver.c
index 9932c5fd6a0..fa4826ac685 100644
--- a/sbin/unwind/resolver.c
+++ b/sbin/unwind/resolver.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resolver.c,v 1.31 2019/04/01 03:31:55 florian Exp $ */
+/* $OpenBSD: resolver.c,v 1.32 2019/04/01 09:24:15 florian Exp $ */
/*
* Copyright (c) 2018 Florian Obser <florian@openbsd.org>
@@ -820,7 +820,6 @@ new_forwarders(void)
log_debug("%s: create_resolver", __func__);
forwarder = create_resolver(FORWARDER);
- set_forwarders(forwarder, &dhcp_forwarder_list);
check_resolver(forwarder);
}
@@ -839,7 +838,6 @@ new_static_forwarders(void)
log_debug("%s: create_resolver", __func__);
static_forwarder = create_resolver(STATIC_FORWARDER);
- set_forwarders(static_forwarder, &resolver_conf->uw_forwarder_list);
check_resolver(static_forwarder);
}
@@ -858,11 +856,6 @@ new_static_dot_forwarders(void)
log_debug("%s: create_resolver", __func__);
static_dot_forwarder = create_resolver(STATIC_DOT_FORWARDER);
- set_forwarders(static_dot_forwarder,
- &resolver_conf->uw_dot_forwarder_list);
- ub_ctx_set_option(static_dot_forwarder->ctx, "tls-cert-bundle:",
- tls_default_ca_cert_file());
- ub_ctx_set_tls(static_dot_forwarder->ctx, 1);
check_resolver(static_dot_forwarder);
}
@@ -928,6 +921,26 @@ create_resolver(enum uw_resolver_type type)
evtimer_set(&res->check_ev, resolver_check_timo, res);
+ switch(res->type) {
+ case RECURSOR:
+ break;
+ case FORWARDER:
+ set_forwarders(res, &dhcp_forwarder_list);
+ break;
+ case STATIC_FORWARDER:
+ set_forwarders(res, &resolver_conf->uw_forwarder_list);
+ break;
+ case STATIC_DOT_FORWARDER:
+ set_forwarders(res, &resolver_conf->uw_dot_forwarder_list);
+ ub_ctx_set_option(res->ctx, "tls-cert-bundle:",
+ tls_default_ca_cert_file());
+ ub_ctx_set_tls(res->ctx, 1);
+ break;
+ case RESOLVER_NONE:
+ fatalx("type NONE");
+ break;
+ }
+
return (res);
}
@@ -984,27 +997,6 @@ check_resolver(struct uw_resolver *res)
if ((data = malloc(sizeof(*data))) == NULL)
fatal("%s", __func__);
- switch(check_res->type) {
- case RECURSOR:
- break;
- case FORWARDER:
- set_forwarders(check_res, &dhcp_forwarder_list);
- break;
- case STATIC_FORWARDER:
- set_forwarders(check_res, &resolver_conf->uw_forwarder_list);
- break;
- case STATIC_DOT_FORWARDER:
- set_forwarders(check_res,
- &resolver_conf->uw_dot_forwarder_list);
- ub_ctx_set_option(check_res->ctx, "tls-cert-bundle:",
- tls_default_ca_cert_file());
- ub_ctx_set_tls(check_res->ctx, 1);
- break;
- case RESOLVER_NONE:
- fatalx("type NONE");
- break;
- }
-
resolver_ref(check_res);
resolver_ref(res);
data->check_res = check_res;