#endif // HAVE_FSTRM
-static void logOutgoingQuery(const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional<Netmask>& srcmask)
+static void logOutgoingQuery(const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, boost::optional<RecProtoBufMessage>& message, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, boost::optional<Netmask>& srcmask)
{
if(!outgoingLoggers)
return;
- RecProtoBufMessage message(DNSProtoBufMessage::OutgoingQuery, uuid, nullptr, &ip, domain, type, QClass::IN, qid, doTCP, bytes);
- message.setServerIdentity(SyncRes::s_serverID);
+ message = RecProtoBufMessage(DNSProtoBufMessage::OutgoingQuery, uuid, nullptr, &ip, domain, type, QClass::IN, qid, doTCP, bytes);
+ message->setServerIdentity(SyncRes::s_serverID);
if (initialRequestId) {
- message.setInitialRequestID(*initialRequestId);
+ message->setInitialRequestID(*initialRequestId);
}
if (srcmask) {
- message.setEDNSSubnet(*srcmask);
+ message->setEDNSSubnet(*srcmask);
}
// cerr <<message.toDebugString()<<endl;
std::string str;
- message.serialize(str);
+ message->serialize(str);
for (auto& logger : *outgoingLoggers) {
logger->queueData(str);
}
}
-static void logIncomingResponse(const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, boost::optional<const boost::uuids::uuid&> initialRequestId, const boost::uuids::uuid& uuid, const ComboAddress& ip, const DNSName& domain, int type, uint16_t qid, bool doTCP, size_t bytes, int rcode, const std::vector<DNSRecord>& records, const struct timeval& queryTime, const std::set<uint16_t>& exportTypes)
+static void logIncomingResponse(const std::shared_ptr<std::vector<std::unique_ptr<RemoteLogger>>>& outgoingLoggers, boost::optional<RecProtoBufMessage>& message, size_t bytes, int rcode, const std::vector<DNSRecord>& records, const struct timeval& queryTime, const std::set<uint16_t>& exportTypes)
{
- if(!outgoingLoggers)
+ if(!outgoingLoggers || !message)
return;
- RecProtoBufMessage message(DNSProtoBufMessage::IncomingResponse, uuid, nullptr, &ip, domain, type, QClass::IN, qid, doTCP, bytes);
- message.setServerIdentity(SyncRes::s_serverID);
- if (initialRequestId) {
- message.setInitialRequestID(*initialRequestId);
- }
- message.setQueryTime(queryTime.tv_sec, queryTime.tv_usec);
- message.setResponseCode(rcode);
- message.addRRs(records, exportTypes);
+ message->updateTime();
+ message->setType(DNSProtoBufMessage::IncomingResponse);
+ message->setBytes(bytes);
+ message->setQueryTime(queryTime.tv_sec, queryTime.tv_usec);
+ message->setResponseCode(rcode);
+ message->addRRs(records, exportTypes);
// cerr <<message.toDebugString()<<endl;
std::string str;
- message.serialize(str);
+ message->serialize(str);
for (auto& logger : *outgoingLoggers) {
logger->queueData(str);
#ifdef HAVE_PROTOBUF
boost::uuids::uuid uuid;
const struct timeval queryTime = *now;
+ boost::optional<RecProtoBufMessage> pbMessage = boost::none;
if (outgoingLoggers) {
uuid = getUniqueID();
- logOutgoingQuery(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask);
+ logOutgoingQuery(outgoingLoggers, pbMessage, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, vpacket.size(), srcmask);
}
#endif /* HAVE_PROTOBUF */
#ifdef HAVE_FSTRM
if(mdp.d_header.rcode == RCode::FormErr && mdp.d_qname.empty() && mdp.d_qtype == 0 && mdp.d_qclass == 0) {
#ifdef HAVE_PROTOBUF
if(outgoingLoggers) {
- logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
+ logIncomingResponse(outgoingLoggers, pbMessage, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
}
#endif
lwr->d_validpacket=true;
#ifdef HAVE_PROTOBUF
if(outgoingLoggers) {
- logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
+ logIncomingResponse(outgoingLoggers, pbMessage, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
}
#endif
lwr->d_validpacket=true;
g_stats.serverParseError++;
#ifdef HAVE_PROTOBUF
if(outgoingLoggers) {
- logIncomingResponse(outgoingLoggers, context ? context->d_initialRequestId : boost::none, uuid, ip, domain, type, qid, doTCP, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
+ logIncomingResponse(outgoingLoggers, pbMessage, len, lwr->d_rcode, lwr->d_records, queryTime, exportTypes);
}
#endif
lwr->d_validpacket=false;