Commit Diff
Diff:
c08c431f3bb99dabd59799318e159bd430a866ea
2ffb795f71e763e7f37a867c5e3869678516207f
Commit:
2ffb795f71e763e7f37a867c5e3869678516207f
Tree:
4fc2a5736730f7bb49ae4e6013c5c9b2f4a2b402
Author:
pjp <pjp@delphinusdns.org>
Committer:
pjp <pjp@delphinusdns.org>
Date:
Mon Nov 4 12:10:49 2019 UTC
Message:
change working with human readable domainnames to machine readable label names when dealing with notifies.
blob - 9c25a3e11054c316b0e9b842d471c211b2882e8d
blob + 98f53563a9ffdce96ad2e85dbbd83adb2b819008
--- ddd-db.h
+++ ddd-db.h
@@ -27,7 +27,7 @@
*/
/*
- * $Id: ddd-db.h,v 1.26 2019/11/04 07:00:40 pjp Exp $
+ * $Id: ddd-db.h,v 1.27 2019/11/04 12:10:49 pjp Exp $
*/
#ifndef _DB_H
@@ -410,6 +410,8 @@ struct rzone {
SLIST_ENTRY(rzone) rzone_entry;
int active;
char *zonename;
+ char *zone;
+ int zonelen;
u_int16_t masterport;
char *master;
struct sockaddr_storage storage;
blob - aca93ff852577a5fd36f338bb4cbb5ae1fa9e7cf
blob + 969fc030d713e84cd4616691edefdf6cca49c4ed
--- delphinusdnsd.c
+++ delphinusdnsd.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: delphinusdnsd.c,v 1.79 2019/11/04 07:00:41 pjp Exp $
+ * $Id: delphinusdnsd.c,v 1.80 2019/11/04 12:10:49 pjp Exp $
*/
@@ -1972,9 +1972,9 @@ axfrentry:
slen = reply_notify(&sreply, NULL);
/* send notify to replicant process */
- idata = strlen(question->converted_name) + 1;
+ idata = question->hdr->namelen;
imsg_compose(ibuf[MY_IMSG_RAXFR], IMSG_NOTIFY_MESSAGE,
- 0, 0, -1, question->converted_name, idata);
+ 0, 0, -1, question->hdr->name, idata);
msgbuf_write(&ibuf[MY_IMSG_RAXFR]->w);
goto udpout;
@@ -1992,9 +1992,9 @@ axfrentry:
build_reply(&sreply, so, buf, len, question, from, fromlen, NULL, NULL, aregion, istcp, 0, NULL, replybuf);
slen = reply_notify(&sreply, NULL);
/* send notify to replicant process */
- idata = strlen(question->converted_name) + 1;
+ idata = question->hdr->namelen;
imsg_compose(ibuf[MY_IMSG_RAXFR], IMSG_NOTIFY_MESSAGE,
- 0, 0, -1, question->converted_name, idata);
+ 0, 0, -1, question->hdr->name, idata);
msgbuf_write(&ibuf[MY_IMSG_RAXFR]->w);
goto udpout;
} else {
@@ -2928,9 +2928,9 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
build_reply(&sreply, so, pbuf, len, question, from, fromlen, NULL, NULL, aregion, istcp, 0, NULL, replybuf);
slen = reply_notify(&sreply, NULL);
/* send notify to replicant process */
- idata = strlen(question->converted_name) + 1;
+ idata = question->hdr->namelen;
imsg_compose(ibuf[MY_IMSG_RAXFR], IMSG_NOTIFY_MESSAGE,
- 0, 0, -1, &question->converted_name, idata);
+ 0, 0, -1, question->hdr->name, idata);
msgbuf_write(&ibuf[MY_IMSG_RAXFR]->w);
goto tcpout;
@@ -2948,9 +2948,9 @@ tcploop(struct cfg *cfg, struct imsgbuf **ibuf)
build_reply(&sreply, so, pbuf, len, question, from, fromlen, NULL, NULL, aregion, istcp, 0, NULL, replybuf);
slen = reply_notify(&sreply, NULL);
/* send notify to replicant process */
- idata = strlen(question->converted_name) + 1;
+ idata = question->hdr->namelen;
imsg_compose(ibuf[MY_IMSG_RAXFR], IMSG_NOTIFY_MESSAGE,
- 0, 0, -1, &question->converted_name, idata);
+ 0, 0, -1, question->hdr->name, idata);
msgbuf_write(&ibuf[MY_IMSG_RAXFR]->w);
goto tcpout;
} else {
blob - fe92a46f9b69048782d27a686d08ffd9721b18e3
blob + c64622f67fa7fda7467c13aac73d9a38535487d2
--- parse.y
+++ parse.y
@@ -21,7 +21,7 @@
*/
/*
- * $Id: parse.y,v 1.80 2019/11/04 09:17:02 pjp Exp $
+ * $Id: parse.y,v 1.81 2019/11/04 12:10:49 pjp Exp $
*/
%{
@@ -741,6 +741,12 @@ rzonestatement:
if (strcmp($1, "zonename") == 0) {
rz->zonename = p;
+
+ rz->zone = dns_label(p, &rz->zonelen);
+ if (rz->zone == NULL) {
+ perror("dns_label");
+ return -1;
+ }
#ifdef __OpenBSD__
if (debug)
printf("at rzone %x, added zonename of %s\n", (unsigned int)rz, p);
blob - 02ed6d80a880436c2b9c6d8a242555d51ff8febc
blob + dc0ecd0ebff8ab038fbd71157761b1464cf7a51c
--- raxfr.c
+++ raxfr.c
@@ -26,7 +26,7 @@
*
*/
/*
- * $Id: raxfr.c,v 1.24 2019/11/04 09:17:02 pjp Exp $
+ * $Id: raxfr.c,v 1.25 2019/11/04 12:10:49 pjp Exp $
*/
#include <sys/types.h>
@@ -1267,6 +1267,7 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
struct imsg imsg;
ssize_t n, datalen;
char *dn = NULL;
+ char *humanconv = NULL;
#if __OpenBSD__
@@ -1393,8 +1394,6 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
- dolog(LOG_DEBUG, "got imsg of type %d\n", imsg.hdr.type);
-
switch(imsg.hdr.type) {
case IMSG_NOTIFY_MESSAGE:
dn = malloc(datalen);
@@ -1404,18 +1403,18 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
}
memcpy(dn, imsg.data, datalen);
- dn[datalen - 1] = '\0';
SLIST_FOREACH(lrz, &rzones, rzone_entry) {
if (lrz->zonename == NULL)
continue;
- if (strcmp(dn, lrz->zonename) == 0)
+ if (datalen == lrz->zonelen &&
+ memcasecmp(lrz->zone, dn, datalen) == 0)
break;
}
if (lrz != NULL) {
- dolog(LOG_DEBUG, "zone %s is being notified now\n", dn);
+ dolog(LOG_DEBUG, "zone %s is being notified now\n", lrz->zonename);
if ((serial = get_remote_soa(lrz)) == MY_SOCK_TIMEOUT) {
dolog(LOG_INFO, "timeout upon notify, dropping\n");
} else if (serial > lrz->soa.serial) {
@@ -1435,9 +1434,13 @@ replicantloop(ddDB *db, struct imsgbuf *ibuf, struct i
* other tasks can still complete.
*/
endspurt = 1;
- }
+ } /* else serial ... */
} else {
- dolog(LOG_DEBUG, "couldn't find a rzone for domainame %s\n", dn);
+ humanconv = convert_name(dn, datalen);
+ if (humanconv != NULL) {
+ dolog(LOG_DEBUG, "couldn't find an rzone for domainame %s\n", humanconv);
+ free(humanconv);
+ }
}
free(dn);
repomaster@centroid.eu