summaryrefslogtreecommitdiff
path: root/daemon/worker.c
diff options
context:
space:
mode:
Diffstat (limited to 'daemon/worker.c')
-rw-r--r--daemon/worker.c47
1 files changed, 35 insertions, 12 deletions
diff --git a/daemon/worker.c b/daemon/worker.c
index ac7053abddf3..389a1de530ec 100644
--- a/daemon/worker.c
+++ b/daemon/worker.c
@@ -58,6 +58,7 @@
#include "services/cache/rrset.h"
#include "services/cache/infra.h"
#include "services/cache/dns.h"
+#include "services/authzone.h"
#include "services/mesh.h"
#include "services/localzone.h"
#include "util/data/msgparse.h"
@@ -1046,7 +1047,7 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
strcasecmp(buf,
worker->daemon->dnscenv->provider_name) == 0)) {
verbose(VERB_ALGO,
- "dnscrypt: not TXT %s. Receive: %s %s",
+ "dnscrypt: not TXT \"%s\". Received: %s \"%s\"",
worker->daemon->dnscenv->provider_name,
sldns_rr_descript(qinfo.qtype)->_name,
buf);
@@ -1251,6 +1252,22 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
server_stats_insrcode(&worker->stats, c->buffer);
goto send_reply;
}
+ if(worker->env.auth_zones &&
+ auth_zones_answer(worker->env.auth_zones, &worker->env,
+ &qinfo, &edns, c->buffer, worker->scratchpad)) {
+ regional_free_all(worker->scratchpad);
+ if(sldns_buffer_limit(c->buffer) == 0) {
+ comm_point_drop_reply(repinfo);
+ return 0;
+ }
+ /* set RA for everyone that can have recursion (based on
+ * access control list) */
+ if(LDNS_RD_WIRE(sldns_buffer_begin(c->buffer)) &&
+ acl != acl_deny_non_local && acl != acl_refuse_non_local)
+ LDNS_RA_SET(sldns_buffer_begin(c->buffer));
+ server_stats_insrcode(&worker->stats, c->buffer);
+ goto send_reply;
+ }
/* We've looked in our local zones. If the answer isn't there, we
* might need to bail out based on ACLs now. */
@@ -1266,13 +1283,9 @@ worker_handle_request(struct comm_point* c, void* arg, int error,
* ACLs allow the snooping. */
if(!(LDNS_RD_WIRE(sldns_buffer_begin(c->buffer))) &&
acl != acl_allow_snoop ) {
- sldns_buffer_set_limit(c->buffer, LDNS_HEADER_SIZE);
- sldns_buffer_write_at(c->buffer, 4,
- (uint8_t*)"\0\0\0\0\0\0\0\0", 8);
- LDNS_QR_SET(sldns_buffer_begin(c->buffer));
- LDNS_RCODE_SET(sldns_buffer_begin(c->buffer),
- LDNS_RCODE_REFUSED);
- sldns_buffer_flip(c->buffer);
+ error_encode(c->buffer, LDNS_RCODE_REFUSED, &qinfo,
+ *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
+ sldns_buffer_read_u16_at(c->buffer, 2), NULL);
regional_free_all(worker->scratchpad);
server_stats_insrcode(&worker->stats, c->buffer);
log_addr(VERB_ALGO, "refused nonrec (cache snoop) query from",
@@ -1326,11 +1339,11 @@ lookup_cache:
h = query_info_hash(lookup_qinfo, sldns_buffer_read_u16_at(c->buffer, 2));
if((e=slabhash_lookup(worker->env.msg_cache, h, lookup_qinfo, 0))) {
/* answer from cache - we have acquired a readlock on it */
- if(answer_from_cache(worker, &qinfo,
+ if(answer_from_cache(worker, &qinfo,
cinfo, &need_drop, &alias_rrset, &partial_rep,
- (struct reply_info*)e->data,
- *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
- sldns_buffer_read_u16_at(c->buffer, 2), repinfo,
+ (struct reply_info*)e->data,
+ *(uint16_t*)(void *)sldns_buffer_begin(c->buffer),
+ sldns_buffer_read_u16_at(c->buffer, 2), repinfo,
&edns)) {
/* prefetch it if the prefetch TTL expired.
* Note that if there is more than one pass
@@ -1672,8 +1685,10 @@ worker_init(struct worker* worker, struct config_file *cfg,
if(worker->thread_num == 0)
log_set_time(worker->env.now);
worker->env.worker = worker;
+ worker->env.worker_base = worker->base;
worker->env.send_query = &worker_send_query;
worker->env.alloc = &worker->alloc;
+ worker->env.outnet = worker->back;
worker->env.rnd = worker->rndstate;
/* If case prefetch is triggered, the corresponding mesh will clear
* the scratchpad for the module env in the middle of request handling.
@@ -1723,6 +1738,14 @@ worker_init(struct worker* worker, struct config_file *cfg,
comm_timer_set(worker->env.probe_timer, &tv);
}
}
+ /* zone transfer tasks, setup once per process, if any */
+ if(worker->env.auth_zones
+#ifndef THREADS_DISABLED
+ && worker->thread_num == 0
+#endif
+ ) {
+ auth_xfer_pickup_initial(worker->env.auth_zones, &worker->env);
+ }
if(!worker->env.mesh || !worker->env.scratch_buffer) {
worker_delete(worker);
return 0;