]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
core_dns: add support for txt records
authorAdam <Adam@anope.org>
Sun, 3 May 2015 23:33:02 +0000 (19:33 -0400)
committerAdam <Adam@anope.org>
Sun, 23 Apr 2017 20:35:21 +0000 (16:35 -0400)
This might be used later by m_dnsbl to get reasons for listings

include/modules/dns.h
src/coremods/core_dns.cpp

index 5f28367618c92acf23d08a170aafa60e30980010..61abd7144288c5a9c904645f900a87521e3eb9c1 100644 (file)
@@ -33,6 +33,8 @@ namespace DNS
                QUERY_CNAME = 5,
                /* Reverse DNS lookup */
                QUERY_PTR = 12,
+               /* TXT */
+               QUERY_TXT = 16,
                /* IPv6 AAAA lookup */
                QUERY_AAAA = 28
        };
index 753b41f430531103556321df6f5b5f190d03ae5a..7ee406a24540f5c97ff9c4b454f5fd587d9801f6 100644 (file)
@@ -154,7 +154,7 @@ class Packet : public Query
                record.ttl = (input[pos] << 24) | (input[pos + 1] << 16) | (input[pos + 2] << 8) | input[pos + 3];
                pos += 4;
 
-               //record.rdlength = input[pos] << 8 | input[pos + 1];
+               uint16_t rdlength = input[pos] << 8 | input[pos + 1];
                pos += 2;
 
                switch (record.type)
@@ -200,6 +200,19 @@ class Packet : public Query
 
                                break;
                        }
+                       case QUERY_TXT:
+                       {
+                               if (pos + rdlength > input_size)
+                                       throw Exception("Unable to unpack txt resource record");
+
+                               record.rdata = std::string(reinterpret_cast<const char *>(input + pos), rdlength);
+                               pos += rdlength;
+
+                               if (record.rdata.find_first_of("\r\n\0", 0, 3) != std::string::npos)
+                                       throw Exception("Invalid character in txt record");
+
+                               break;
+                       }
                        default:
                                break;
                }