]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add support of CNAME requests to the lua resolver
authorVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 11 Aug 2022 20:36:50 +0000 (21:36 +0100)
committerVsevolod Stakhov <vsevolod@rspamd.com>
Thu, 11 Aug 2022 20:36:50 +0000 (21:36 +0100)
contrib/librdns/util.c
src/lua/lua_dns_resolver.c

index b20b327bc0d89cad407f8240b70270ccc345f367..0172ce00ebcb785702303f2c2837ec490c5a7e45 100644 (file)
@@ -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)";
        }
 
 }
index 9a9201f0ec6bc64b931874fcac8a31e3916e2859..5bee37627444a56953eccefe674efda109fa20f0 100644 (file)
@@ -278,6 +278,10 @@ lua_push_dns_reply (lua_State *L, const struct rdns_reply *reply)
                                lua_pushinteger (L, elt->content.soa.minimum);
                                lua_settable (L, -3);
 
+                               lua_rawseti (L, -2, ++i);
+                               break;
+                       case RDNS_REQUEST_CNAME:
+                               lua_pushstring (L, elt->content.cname.name);
                                lua_rawseti (L, -2, ++i);
                                break;
                        default:
@@ -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);