aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rspamd.com>2022-08-11 21:36:50 +0100
committerVsevolod Stakhov <vsevolod@rspamd.com>2022-08-11 21:36:50 +0100
commit33f69f85ea3c7f27ac3a98a5eaf8ed0d232110fd (patch)
tree6e1c6ab5f7241673a9988a2d7ba3af4daa0bf93b
parentb8456ec01d76b1c0fb3e50182d12f3cfcacade51 (diff)
downloadrspamd-33f69f85ea3c7f27ac3a98a5eaf8ed0d232110fd.tar.gz
rspamd-33f69f85ea3c7f27ac3a98a5eaf8ed0d232110fd.zip
[Minor] Add support of CNAME requests to the lua resolver
-rw-r--r--contrib/librdns/util.c57
-rw-r--r--src/lua/lua_dns_resolver.c5
2 files changed, 36 insertions, 26 deletions
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index b20b327bc..0172ce00e 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -306,6 +306,9 @@ rdns_type_fromstr (const char *str)
else if (strcmp (str, "tlsa") == 0) {
return RDNS_REQUEST_TLSA;
}
+ else if (strcmp (str, "cname") == 0) {
+ return RDNS_REQUEST_CNAME;
+ }
else if (strcmp (str, "any") == 0) {
return RDNS_REQUEST_ANY;
}
@@ -318,32 +321,34 @@ const char *
rdns_str_from_type (enum rdns_request_type rcode)
{
switch (rcode) {
- case RDNS_REQUEST_INVALID:
- return "(invalid)";
- case RDNS_REQUEST_A:
- return "a";
- case RDNS_REQUEST_NS:
- return "ns";
- case RDNS_REQUEST_SOA:
- return "soa";
- case RDNS_REQUEST_PTR:
- return "ptr";
- case RDNS_REQUEST_MX:
- return "mx";
- case RDNS_REQUEST_TXT:
- return "txt";
- case RDNS_REQUEST_SRV:
- return "srv";
- case RDNS_REQUEST_SPF:
- return "spf";
- case RDNS_REQUEST_AAAA:
- return "aaaa";
- case RDNS_REQUEST_TLSA:
- return "tlsa";
- case RDNS_REQUEST_ANY:
- return "any";
- default:
- return "(unknown)";
+ case RDNS_REQUEST_INVALID:
+ return "(invalid)";
+ case RDNS_REQUEST_A:
+ return "a";
+ case RDNS_REQUEST_NS:
+ return "ns";
+ case RDNS_REQUEST_SOA:
+ return "soa";
+ case RDNS_REQUEST_PTR:
+ return "ptr";
+ case RDNS_REQUEST_MX:
+ return "mx";
+ case RDNS_REQUEST_TXT:
+ return "txt";
+ case RDNS_REQUEST_SRV:
+ return "srv";
+ case RDNS_REQUEST_SPF:
+ return "spf";
+ case RDNS_REQUEST_AAAA:
+ return "aaaa";
+ case RDNS_REQUEST_TLSA:
+ return "tlsa";
+ case RDNS_REQUEST_CNAME:
+ return "cname";
+ case RDNS_REQUEST_ANY:
+ return "any";
+ default:
+ return "(unknown)";
}
}
diff --git a/src/lua/lua_dns_resolver.c b/src/lua/lua_dns_resolver.c
index 9a9201f0e..5bee37627 100644
--- a/src/lua/lua_dns_resolver.c
+++ b/src/lua/lua_dns_resolver.c
@@ -280,6 +280,10 @@ lua_push_dns_reply (lua_State *L, const struct rdns_reply *reply)
lua_rawseti (L, -2, ++i);
break;
+ case RDNS_REQUEST_CNAME:
+ lua_pushstring (L, elt->content.cname.name);
+ lua_rawseti (L, -2, ++i);
+ break;
default:
continue;
}
@@ -743,6 +747,7 @@ luaopen_dns_resolver (lua_State * L)
LUA_ENUM (L, DNS_SPF, RDNS_REQUEST_SPF);
LUA_ENUM (L, DNS_AAAA, RDNS_REQUEST_AAAA);
LUA_ENUM (L, DNS_SOA, RDNS_REQUEST_SOA);
+ LUA_ENUM (L, DNS_CNAME, RDNS_REQUEST_CNAME);
}
lua_pop (L, 1);