dq.qTag->add(tag.first, tag.second);
}
- });
-
+ });
g_lua.registerFunction<string(DNSQuestion::*)(std::string)>("getTag", [](const DNSQuestion& dq, const std::string& strLabel) {
- std::string strValue;
- if(dq.qTag != nullptr) {
- strValue = dq.qTag->getMatch(strLabel);
- }
- return strValue;
+ std::string strValue;
+ if(dq.qTag != nullptr) {
+ strValue = dq.qTag->getMatch(strLabel);
+ }
+ return strValue;
- });
+ });
g_lua.registerFunction<std::unordered_map<string, string>(DNSQuestion::*)(void)>("getTagArray", [](const DNSQuestion& dq) {
- if(dq.qTag != nullptr) {
- return dq.qTag->tagData;
- } else {
- std::unordered_map<string, string> XX;
- return XX;
- }
- });
+ if(dq.qTag != nullptr) {
+ return dq.qTag->tagData;
+ } else {
+ std::unordered_map<string, string> XX;
+ return XX;
+ }
+ });
/* DNSQuestion bindings */
class QTag
{
-
public:
+ QTag()
+ {
+ }
-QTag()
-{
-}
-
-~QTag()
-{
-}
-
-void add(const std::string strLabel, const std::string strValue)
-{
- tagData.insert( {strLabel, strValue});
- return;
-}
+ ~QTag()
+ {
+ }
-std::string getMatch(const std::string& strLabel) const
-{
- std::unordered_map<std::string, std::string>::const_iterator got =tagData.find (strLabel);
- if(got == tagData.end()) {
- return "";
- } else {
- return got->second;
+ void add(const std::string strLabel, const std::string strValue)
+ {
+ tagData.insert( {strLabel, strValue});
+ return;
}
-}
-std::string getEntry(size_t iEntry) const
-{
- std::string strEntry;
- size_t iCounter = 0;
-
- for (const auto& itr : tagData) {
- iCounter++;
- if(iCounter == iEntry) {
- strEntry = itr.first;
- strEntry += strSep;
- strEntry += itr.second;
- break;
+ std::string getMatch(const std::string& strLabel) const
+ {
+ std::unordered_map<std::string, std::string>::const_iterator got =tagData.find (strLabel);
+ if(got == tagData.end()) {
+ return "";
+ } else {
+ return got->second;
}
}
- return strEntry;
+ std::string getEntry(size_t iEntry) const
+ {
+ std::string strEntry;
+ size_t iCounter = 0;
+
+ for (const auto& itr : tagData) {
+ iCounter++;
+ if(iCounter == iEntry) {
+ strEntry = itr.first;
+ strEntry += strSep;
+ strEntry += itr.second;
+ break;
+ }
+ }
-}
+ return strEntry;
+ }
-size_t count() const
-{
- return tagData.size();
-}
+ size_t count() const
+ {
+ return tagData.size();
+ }
-std::string dumpString() const
-{
- std::string strRet;
+ std::string dumpString() const
+ {
+ std::string strRet;
- for (const auto& itr : tagData) {
- strRet += itr.first;
- strRet += strSep;
- strRet += itr.second;
- strRet += "\n";
+ for (const auto& itr : tagData) {
+ strRet += itr.first;
+ strRet += strSep;
+ strRet += itr.second;
+ strRet += "\n";
+ }
+ return strRet;
}
- return strRet;
-}
-
-public:
std::unordered_map<std::string, std::string>tagData;
private:
const bool tcp;
bool skipCache{false};
bool ecsOverride;
- bool useECS{true};
-
+ bool useECS{true};
};
struct DNSResponse : DNSQuestion