diff --git a/llarp/dns/dns.hpp b/llarp/dns/dns.hpp index 01377a4c5..55c34bcc9 100644 --- a/llarp/dns/dns.hpp +++ b/llarp/dns/dns.hpp @@ -7,6 +7,7 @@ namespace llarp { namespace dns { + constexpr uint16_t qTypeAAAA = 28; constexpr uint16_t qTypeTXT = 16; constexpr uint16_t qTypeMX = 15; constexpr uint16_t qTypePTR = 12; diff --git a/llarp/dns/message.cpp b/llarp/dns/message.cpp index 67d4f48f9..dcb28aca8 100644 --- a/llarp/dns/message.cpp +++ b/llarp/dns/message.cpp @@ -247,14 +247,17 @@ namespace llarp { hdr_fields |= (1 << 15) | (1 << 3); const auto& question = questions[0]; - answers.emplace_back(); - auto& nx = answers.back(); - nx.rr_name = question.qname; - nx.rr_type = question.qtype; - nx.rr_class = question.qclass; - nx.ttl = ttl; - nx.rData.resize(1); - nx.rData.data()[0] = 0; + if(question.qtype != qTypeAAAA) + { + answers.emplace_back(); + auto& nx = answers.back(); + nx.rr_name = question.qname; + nx.rr_type = question.qtype; + nx.rr_class = question.qclass; + nx.ttl = ttl; + nx.rData.resize(1); + nx.rData.data()[0] = 0; + } } } diff --git a/llarp/handlers/tun.cpp b/llarp/handlers/tun.cpp index c07de2fb4..1224a7595 100644 --- a/llarp/handlers/tun.cpp +++ b/llarp/handlers/tun.cpp @@ -246,17 +246,9 @@ namespace llarp } else if(msg.questions[0].qtype == dns::qTypeA) { - // forward dns llarp::service::Address addr; - if(qname == "random.snode" || qname == "random.snode.") - { - RouterID random; - if(Router()->GetRandomGoodRouter(random)) - msg.AddCNAMEReply(random.ToString(), 1); - else - msg.AddNXReply(); - } - else if(msg.questions[0].qname == "localhost.loki" + // forward dns + if(msg.questions[0].qname == "localhost.loki" || msg.questions[0].qname == "localhost.loki.") { size_t counter = 0; @@ -351,18 +343,17 @@ namespace llarp // hook random.snode for CNAME if(msg.questions[0].qname == "random.snode" || msg.questions[0].qname == "random.snode.") - return msg.questions[0].qtype == llarp::dns::qTypeCNAME; - // hook localhost.loki for CNAME and A records + return true; + // hook localhost.loki if(msg.questions[0].qname == "localhost.loki" || msg.questions[0].qname == "localhost.loki.") - return msg.questions[0].qtype == llarp::dns::qTypeCNAME - || msg.questions[0].qtype == llarp::dns::qTypeA; + return true; // hook .loki A records if(addr.FromString(msg.questions[0].qname, ".loki")) - return msg.questions[0].qtype == llarp::dns::qTypeA; + return true; // hook .snode A records if(addr.FromString(msg.questions[0].qname, ".snode")) - return msg.questions[0].qtype == llarp::dns::qTypeA; + return true; // hook any ranges we own if(msg.questions[0].qtype == llarp::dns::qTypePTR) {