}
//! look up qname target with r->qtype, plonk it in the answer section of 'r' with name aname
-bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname)
+bool DNSProxy::completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname, const uint8_t scopeMask)
{
if(r->d_tcp) {
vector<DNSZoneRecord> ips;
for (auto &ip : ips)
{
ip.dr.d_name = aname;
+ ip.scopeMask = scopeMask;
r->addRecord(ip);
}
ce.anyLocal = r->d_anyLocal;
ce.complete = r;
ce.aname=aname;
+ ce.anameScopeMask = scopeMask;
d_conntrack[id]=ce;
}
if(j->first.d_type == i->second.qtype || (i->second.qtype == QType::ANY && (j->first.d_type == QType::A || j->first.d_type == QType::AAAA))) {
DNSZoneRecord dzr;
dzr.dr.d_name=i->second.aname;
+ dzr.scopeMask=i->second.anameScopeMask;
dzr.dr.d_type = j->first.d_type;
dzr.dr.d_ttl=j->first.d_ttl;
dzr.dr.d_place= j->first.d_place;
DNSProxy(const string &ip); //!< creates socket
~DNSProxy(); //<! dtor for DNSProxy
void go(); //!< launches the actual thread
- bool completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname);
+ bool completePacket(DNSPacket *r, const DNSName& target,const DNSName& aname, const uint8_t scopeMask);
void mainloop(); //!< this is the main loop that receives reply packets and sends them out again
static void *launchhelper(void *p)
DNSName qname;
DNSPacket* complete;
DNSName aname;
+ uint8_t anameScopeMask;
ComboAddress remote;
uint16_t id;
uint16_t qtype;
vector<DNSZoneRecord> rrset;
bool weDone=0, weRedirected=0, weHaveUnauth=0;
DNSName haveAlias;
+ uint8_t aliasScopeMask;
DNSPacket *r=0;
bool noCache=false;
B.lookup(QType(QType::ANY), target, p, sd.domain_id);
rrset.clear();
haveAlias.trimToLabels(0);
+ aliasScopeMask = 0;
weDone = weRedirected = weHaveUnauth = false;
while(B.get(rr)) {
continue;
}
haveAlias=getRR<ALIASRecordContent>(rr.dr)->d_content;
+ aliasScopeMask=rr.scopeMask;
}
// Filter out all SOA's and add them in later
if(!haveAlias.empty() && (!weDone || p->qtype.getCode() == QType::ANY)) {
DLOG(L<<Logger::Warning<<"Found nothing that matched for '"<<target<<"', but did get alias to '"<<haveAlias<<"', referring"<<endl);
- DP->completePacket(r, haveAlias, target);
+ DP->completePacket(r, haveAlias, target, aliasScopeMask);
return 0;
}