correctly encode response

pull/103/head
Jeff Becker 6 years ago
parent 1f104881be
commit e1ee2de38a
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -1,6 +1,7 @@
#include <llarp/dns/message.hpp>
#include <llarp/endian.hpp>
#include <llarp/logger.hpp>
#include <llarp/buffer.hpp>
namespace llarp
{
@ -172,13 +173,19 @@ namespace llarp
hdr_fields |= (1 << 15);
const auto& question = questions[0];
answers.emplace_back();
auto& rec = answers.back();
rec.rr_name = question.qname;
rec.rr_type = question.qtype;
rec.rr_class = 1;
rec.ttl = 1;
rec.rData.resize(name.size());
memcpy(rec.rData.data(), name.c_str(), rec.rData.size());
auto& rec = answers.back();
rec.rr_name = question.qname;
rec.rr_type = question.qtype;
rec.rr_class = 1;
rec.ttl = 1;
byte_t tmp[512] = {0};
auto buf = llarp::StackBuffer< decltype(tmp) >(tmp);
if(EncodeName(&buf, name))
{
buf.sz = buf.cur - buf.base;
rec.rData.resize(buf.sz);
memcpy(rec.rData.data(), buf.base, buf.sz);
}
}
}

Loading…
Cancel
Save