test ECS information is passed in dlzexternal

the dlzexternal test driver now includes ECS, if present in the
query, in the TXT record returned for QNAME "source-addr".
This commit is contained in:
Evan Hunt
2021-11-02 23:06:10 -07:00
parent f81debe1c8
commit 79ddedabf8
4 changed files with 28 additions and 3 deletions

View File

@@ -488,6 +488,7 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
}
if (strcmp(name, "source-addr") == 0) {
char ecsbuf[DNS_ECS_FORMATSIZE] = "not supported";
strncpy(buf, "unknown", sizeof(buf));
if (methods != NULL && methods->sourceip != NULL &&
(methods->version - methods->age <=
@@ -497,6 +498,17 @@ dlz_lookup(const char *zone, const char *name, void *dbdata,
methods->sourceip(clientinfo, &src);
fmt_address(src, buf, sizeof(buf));
}
if (clientinfo != NULL && clientinfo->version >= 3) {
if (clientinfo->ecs.addr.family != AF_UNSPEC) {
dns_ecs_format(&clientinfo->ecs, ecsbuf,
sizeof(ecsbuf));
} else {
snprintf(ecsbuf, sizeof(ecsbuf), "%s",
"not present");
}
}
i = strlen(buf);
snprintf(buf + i, sizeof(buf) - i - 1, " ECS %s", ecsbuf);
loginfo("dlz_example: lookup connection from %s", buf);