Browse Source

Added QDnsPacket makeSimpleQuery method

develop
Robin Thoni 6 years ago
parent
commit
0db44f2b79

+ 2
- 0
src/modules/dns-base/includes/dns-base/QDnsPacket.h View File

@@ -53,6 +53,8 @@ namespace QDns
53 53
 
54 54
             void setAdditionalRecords(const QList<QDnsResourceRecord> &additionalRecords);
55 55
 
56
+            static QDnsPacket makeSimpleQuery(const QString& host, RecordType type);
57
+
56 58
         private:
57 59
             void parse(const QByteArray &data, QDataStream &dataStream);
58 60
 

+ 15
- 0
src/modules/dns-base/src/QDnsPacket.cpp View File

@@ -179,5 +179,20 @@ namespace QDns
179 179
             m_additionalRecords = additionalRecords;
180 180
             m_header.setAdditionalCount((quint16) m_additionalRecords.length());
181 181
         }
182
+
183
+        QDnsPacket QDnsPacket::makeSimpleQuery(const QString& host, RecordType type)
184
+        {
185
+            QDns::Base::QDnsPacket packet;
186
+            auto header = packet.getHeader();
187
+            header.setIsQuery(true);
188
+            header.setIsRecursionDesired(true);
189
+            packet.setHeader(header);
190
+            QDns::Base::QDnsQuery query;
191
+            query.setName(host);
192
+            query.setClass(QDns::Base::RecordClass::IN);
193
+            query.setType(type);
194
+            packet.setQueries(QList<QDns::Base::QDnsQuery>() << query);
195
+            return packet;
196
+        }
182 197
     }
183 198
 }

Loading…
Cancel
Save