summaryrefslogtreecommitdiff
path: root/src/coremods
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2015-05-03 19:33:02 -0400
committerAdam <Adam@anope.org>2017-04-23 16:35:21 -0400
commitf2e3762ff4a2b3690ed70eba5cc0dde9ae045a90 (patch)
treebecc8333f43a3d0aa6f3ba4ac8c459158d740a6d /src/coremods
parent127683c29e6eb33c21f85cf1ccba6fb85fc0cdec (diff)
core_dns: add support for txt records
This might be used later by m_dnsbl to get reasons for listings
Diffstat (limited to 'src/coremods')
-rw-r--r--src/coremods/core_dns.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/coremods/core_dns.cpp b/src/coremods/core_dns.cpp
index 753b41f43..7ee406a24 100644
--- a/src/coremods/core_dns.cpp
+++ b/src/coremods/core_dns.cpp
@@ -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;
}