diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:34:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:34:30 +0000 |
commit | 4fc2f55f761d71aae1f145d5aa94ba929cc39676 (patch) | |
tree | 5c1e1db3b46dd4edbe11f612d93cb94b96891ce3 /dnsdist-idstate.cc | |
parent | Initial commit. (diff) | |
download | dnsdist-4b05eb2196d01b29234ea3da7b08514b75478e45.tar.xz dnsdist-4b05eb2196d01b29234ea3da7b08514b75478e45.zip |
Adding upstream version 1.7.3.upstream/1.7.3upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dnsdist-idstate.cc')
-rw-r--r-- | dnsdist-idstate.cc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/dnsdist-idstate.cc b/dnsdist-idstate.cc new file mode 100644 index 0000000..286808c --- /dev/null +++ b/dnsdist-idstate.cc @@ -0,0 +1,75 @@ + +#include "dnsdist.hh" + +DNSResponse makeDNSResponseFromIDState(IDState& ids, PacketBuffer& data) +{ + DNSResponse dr(&ids.qname, ids.qtype, ids.qclass, &ids.origDest, &ids.origRemote, data, ids.protocol, &ids.sentTime.d_start); + dr.origFlags = ids.origFlags; + dr.cacheFlags = ids.cacheFlags; + dr.ecsAdded = ids.ecsAdded; + dr.ednsAdded = ids.ednsAdded; + dr.useZeroScope = ids.useZeroScope; + dr.packetCache = std::move(ids.packetCache); + dr.delayMsec = ids.delayMsec; + dr.skipCache = ids.skipCache; + dr.cacheKey = ids.cacheKey; + dr.cacheKeyNoECS = ids.cacheKeyNoECS; + dr.cacheKeyUDP = ids.cacheKeyUDP; + dr.dnssecOK = ids.dnssecOK; + dr.tempFailureTTL = ids.tempFailureTTL; + dr.qTag = std::move(ids.qTag); + dr.subnet = std::move(ids.subnet); + dr.uniqueId = std::move(ids.uniqueId); + + if (ids.dnsCryptQuery) { + dr.dnsCryptQuery = std::move(ids.dnsCryptQuery); + } + + dr.hopRemote = &ids.hopRemote; + dr.hopLocal = &ids.hopLocal; + + return dr; +} + +void setIDStateFromDNSQuestion(IDState& ids, DNSQuestion& dq, DNSName&& qname) +{ + ids.origRemote = *dq.remote; + ids.origDest = *dq.local; + ids.sentTime.set(*dq.queryTime); + ids.qname = std::move(qname); + ids.qtype = dq.qtype; + ids.qclass = dq.qclass; + ids.protocol = dq.protocol; + ids.delayMsec = dq.delayMsec; + ids.tempFailureTTL = dq.tempFailureTTL; + ids.origFlags = dq.origFlags; + ids.cacheFlags = dq.cacheFlags; + ids.cacheKey = dq.cacheKey; + ids.cacheKeyNoECS = dq.cacheKeyNoECS; + ids.cacheKeyUDP = dq.cacheKeyUDP; + ids.subnet = dq.subnet; + ids.skipCache = dq.skipCache; + ids.packetCache = dq.packetCache; + ids.ednsAdded = dq.ednsAdded; + ids.ecsAdded = dq.ecsAdded; + ids.useZeroScope = dq.useZeroScope; + ids.qTag = std::move(dq.qTag); + ids.dnssecOK = dq.dnssecOK; + ids.uniqueId = std::move(dq.uniqueId); + + if (dq.hopRemote) { + ids.hopRemote = *dq.hopRemote; + } + else { + ids.hopRemote.sin4.sin_family = 0; + } + + if (dq.hopLocal) { + ids.hopLocal = *dq.hopLocal; + } + else { + ids.hopLocal.sin4.sin_family = 0; + } + + ids.dnsCryptQuery = std::move(dq.dnsCryptQuery); +} |