Skip to content

Commit

Permalink
Represent scope as a prefix length and not a full Netmask (ip + prefi…
Browse files Browse the repository at this point in the history
…x) object
omoerbeek committed Jan 15, 2025
1 parent 7d8b8aa commit 82933fa
Showing 25 changed files with 213 additions and 187 deletions.
4 changes: 2 additions & 2 deletions pdns/calidns.cc
Original file line number Diff line number Diff line change
@@ -243,8 +243,8 @@ void parseQueryFile(const std::string& queryFile, vector<std::shared_ptr<vector<

if (!subnet.empty() || addECS) {
EDNSSubnetOpts opt;
opt.source = Netmask(subnet.empty() ? "0.0.0.0/32" : subnet);
ednsOptions.emplace_back(EDNSOptionCode::ECS, makeEDNSSubnetOptsString(opt));
opt.setSource(Netmask(subnet.empty() ? "0.0.0.0/32" : subnet));
ednsOptions.emplace_back(EDNSOptionCode::ECS, opt.makeOptString());
}

if (!ednsOptions.empty() || (packetWriter.getHeader()->id % 2) != 0) {
4 changes: 2 additions & 2 deletions pdns/dnsdistdist/dnsdist-cache.cc
Original file line number Diff line number Diff line change
@@ -65,8 +65,8 @@ bool DNSDistPacketCache::getClientSubnet(const PacketBuffer& packet, size_t qnam

EDNSSubnetOpts eso;
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
if (getEDNSSubnetOptsFromString(reinterpret_cast<const char*>(&packet.at(optRDPosition + ecsOptionStartPosition + (EDNS_OPTION_CODE_SIZE + EDNS_OPTION_LENGTH_SIZE))), ecsOptionSize - (EDNS_OPTION_CODE_SIZE + EDNS_OPTION_LENGTH_SIZE), &eso)) {
subnet = eso.source;
if (EDNSSubnetOpts::getFromString(reinterpret_cast<const char*>(&packet.at(optRDPosition + ecsOptionStartPosition + (EDNS_OPTION_CODE_SIZE + EDNS_OPTION_LENGTH_SIZE))), ecsOptionSize - (EDNS_OPTION_CODE_SIZE + EDNS_OPTION_LENGTH_SIZE), &eso)) {
subnet = eso.getSource();
return true;
}
}
4 changes: 2 additions & 2 deletions pdns/dnsdistdist/dnsdist-ecs.cc
Original file line number Diff line number Diff line change
@@ -436,8 +436,8 @@ void generateECSOption(const ComboAddress& source, string& res, uint16_t ECSPref
{
Netmask sourceNetmask(source, ECSPrefixLength);
EDNSSubnetOpts ecsOpts;
ecsOpts.source = sourceNetmask;
string payload = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(sourceNetmask);
string payload = ecsOpts.makeOptString();
generateEDNSOption(EDNSOptionCode::ECS, payload, res);
}

81 changes: 40 additions & 41 deletions pdns/dnsdistdist/test-dnsdist_cc.cc
Original file line number Diff line number Diff line change
@@ -478,8 +478,8 @@ BOOST_AUTO_TEST_CASE(replaceECSWithSameSize)
GenericDNSPacketWriter<PacketBuffer> packetWriter(query, name, QType::A, QClass::IN, 0);
packetWriter.getHeader()->rd = 1;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -518,8 +518,8 @@ BOOST_AUTO_TEST_CASE(replaceECSWithSameSizeAlreadyParsed)
GenericDNSPacketWriter<PacketBuffer> packetWriter(query, ids.qname, QType::A, QClass::IN, 0);
packetWriter.getHeader()->rd = 1;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -565,8 +565,8 @@ BOOST_AUTO_TEST_CASE(replaceECSWithSmaller)
GenericDNSPacketWriter<PacketBuffer> packetWriter(query, name, QType::A, QClass::IN, 0);
packetWriter.getHeader()->rd = 1;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, 32);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 32));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -605,8 +605,8 @@ BOOST_AUTO_TEST_CASE(replaceECSWithLarger)
EDNSSubnetOpts ecsOpts;
// smaller (less specific so less bits) option
static_assert(8 < ECSSourcePrefixV4, "The ECS scope should be smaller");
ecsOpts.source = Netmask(origRemote, 8);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 8));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -661,8 +661,8 @@ BOOST_AUTO_TEST_CASE(replaceECSFollowedByTSIG)
GenericDNSPacketWriter<PacketBuffer> packetWriter(query, name, QType::A, QClass::IN, 0);
packetWriter.getHeader()->rd = 1;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, 8);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 8));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -720,8 +720,8 @@ BOOST_AUTO_TEST_CASE(replaceECSAfterAN)
packetWriter.startRecord(DNSName("powerdns.com."), QType::A, 0, QClass::IN, DNSResourceRecord::ANSWER, true);
packetWriter.commit();
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, 8);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 8));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -778,8 +778,8 @@ BOOST_AUTO_TEST_CASE(replaceECSAfterAuth)
packetWriter.startRecord(DNSName("powerdns.com."), QType::A, 0, QClass::IN, DNSResourceRecord::AUTHORITY, true);
packetWriter.commit();
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, 8);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 8));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.addOpt(512, 0, 0, opts);
@@ -834,8 +834,8 @@ BOOST_AUTO_TEST_CASE(replaceECSBetweenTwoRecords)
GenericDNSPacketWriter<PacketBuffer> packetWriter(query, name, QType::A, QClass::IN, 0);
packetWriter.getHeader()->rd = 1;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, 8);
string origECSOption = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, 8));
string origECSOption = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOption);
packetWriter.startRecord(DNSName("additional"), QType::A, 0, QClass::IN, DNSResourceRecord::ADDITIONAL, false);
@@ -1099,8 +1099,8 @@ BOOST_AUTO_TEST_CASE(removeECSWhenOnlyOption)
packetWriter.commit();

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOptionStr);
packetWriter.addOpt(512, 0, 0, opts);
@@ -1149,8 +1149,8 @@ BOOST_AUTO_TEST_CASE(removeECSWhenFirstOption)
packetWriter.commit();

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV6);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV6));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
@@ -1202,9 +1202,8 @@ BOOST_AUTO_TEST_CASE(removeECSWhenIntermediaryOption)
packetWriter.commit();

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);

ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr1 = cookiesOpt.makeOptString();
string cookiesOptionStr2 = cookiesOpt.makeOptString();
@@ -1261,8 +1260,8 @@ BOOST_AUTO_TEST_CASE(removeECSWhenLastOption)
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::COOKIE, cookiesOptionStr);
opts.emplace_back(EDNSOptionCode::ECS, origECSOptionStr);
@@ -1308,8 +1307,8 @@ BOOST_AUTO_TEST_CASE(rewritingWithoutECSWhenOnlyOption)
packetWriter.xfr32BitInt(0x01020304);

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, origECSOptionStr);
packetWriter.addOpt(512, 0, 0, opts);
@@ -1347,8 +1346,8 @@ BOOST_AUTO_TEST_CASE(rewritingWithoutECSWhenFirstOption)
packetWriter.xfr32BitInt(0x01020304);

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
@@ -1389,8 +1388,8 @@ BOOST_AUTO_TEST_CASE(rewritingWithoutECSWhenIntermediaryOption)
packetWriter.xfr32BitInt(0x01020304);

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr1 = cookiesOpt.makeOptString();
string cookiesOptionStr2 = cookiesOpt.makeOptString();
@@ -1433,8 +1432,8 @@ BOOST_AUTO_TEST_CASE(rewritingWithoutECSWhenLastOption)
packetWriter.xfr32BitInt(0x01020304);

EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(origRemote, ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(origRemote, ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
@@ -1500,8 +1499,8 @@ BOOST_AUTO_TEST_CASE(test_getEDNSZ)
uint16_t qtype = QType::A;
uint16_t qclass = QClass::IN;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
@@ -1730,8 +1729,8 @@ BOOST_AUTO_TEST_CASE(test_addEDNSToQueryTurnedResponse)
uint16_t zValue = 0;
uint16_t udpPayloadSize = 0;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4);
string origECSOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4));
string origECSOptionStr = ecsOpts.makeOptString();
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
string cookiesOptionStr = cookiesOpt.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
@@ -1849,8 +1848,8 @@ BOOST_AUTO_TEST_CASE(test_getEDNSOptionsStart)
const uint16_t qtype = QType::A;
const uint16_t qclass = QClass::IN;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4);
const string ecsOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4));
const string ecsOptionStr = ecsOpts.makeOptString();
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
opts.emplace_back(EDNSOptionCode::ECS, ecsOptionStr);
const ComboAddress rem("127.0.0.1");
@@ -1949,8 +1948,8 @@ BOOST_AUTO_TEST_CASE(test_isEDNSOptionInOpt)
const uint16_t qtype = QType::A;
const uint16_t qclass = QClass::IN;
EDNSSubnetOpts ecsOpts;
ecsOpts.source = Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4);
const string ecsOptionStr = makeEDNSSubnetOptsString(ecsOpts);
ecsOpts.setSource(Netmask(ComboAddress("127.0.0.1"), ECSSourcePrefixV4));
const string ecsOptionStr = ecsOpts.makeOptString();
const size_t sizeOfECSContent = ecsOptionStr.size();
const size_t sizeOfECSOption = /* option code */ 2 + /* option length */ 2 + sizeOfECSContent;
EDNSCookiesOpt cookiesOpt("deadbeefdeadbeef");
8 changes: 4 additions & 4 deletions pdns/dnsdistdist/test-dnsdistedns.cc
Original file line number Diff line number Diff line change
@@ -135,8 +135,8 @@ BOOST_AUTO_TEST_CASE(getExtendedDNSError)
.extraText = "Synthesized from aggressive NSEC cache"};
opts.emplace_back(EDNSOptionCode::EXTENDEDERROR, makeEDNSExtendedErrorOptString(ede));
EDNSSubnetOpts ecsOpt;
ecsOpt.source = Netmask(ComboAddress("192.0.2.1"), 24U);
const auto ecsOptStr = makeEDNSSubnetOptsString(ecsOpt);
ecsOpt.setSource(Netmask(ComboAddress("192.0.2.1"), 24U));
const auto ecsOptStr = ecsOpt.makeOptString();
opts.emplace_back(EDNSOptionCode::ECS, ecsOptStr);
pw.addOpt(512, 0, 0, opts);
pw.commit();
@@ -155,8 +155,8 @@ BOOST_AUTO_TEST_CASE(getExtendedDNSError)
pw.getHeader()->rd = 1;
GenericDNSPacketWriter<PacketBuffer>::optvect_t opts;
EDNSSubnetOpts ecsOpt;
ecsOpt.source = Netmask(ComboAddress("192.0.2.1"), 24U);
const auto ecsOptStr = makeEDNSSubnetOptsString(ecsOpt);
ecsOpt.setSource(Netmask(ComboAddress("192.0.2.1"), 24U));
const auto ecsOptStr = ecsOpt.makeOptString();
opts.emplace_back(EDNSOptionCode::ECS, ecsOptStr);
const EDNSExtendedError ede{
.infoCode = static_cast<uint16_t>(EDNSExtendedError::code::Synthesized),
14 changes: 7 additions & 7 deletions pdns/dnsdistdist/test-dnsdistpacketcache_cc.cc
Original file line number Diff line number Diff line change
@@ -801,8 +801,8 @@ BOOST_AUTO_TEST_CASE(test_PCCollision)
pwQ.getHeader()->id = qid;
GenericDNSPacketWriter<PacketBuffer>::optvect_t ednsOptions;
EDNSSubnetOpts opt;
opt.source = Netmask("10.0.59.220/32");
ednsOptions.emplace_back(EDNSOptionCode::ECS, makeEDNSSubnetOptsString(opt));
opt.setSource(Netmask("10.0.59.220/32"));
ednsOptions.emplace_back(EDNSOptionCode::ECS, opt.makeOptString());
pwQ.addOpt(512, 0, 0, ednsOptions);
pwQ.commit();

@@ -812,7 +812,7 @@ BOOST_AUTO_TEST_CASE(test_PCCollision)
bool found = localCache.get(dnsQuestion, 0, &key, subnetOut, dnssecOK, receivedOverUDP);
BOOST_CHECK_EQUAL(found, false);
BOOST_REQUIRE(subnetOut);
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.source.toString());
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.getSource().toString());

PacketBuffer response;
GenericDNSPacketWriter<PacketBuffer> pwR(response, ids.qname, ids.qtype, QClass::IN, 0);
@@ -831,7 +831,7 @@ BOOST_AUTO_TEST_CASE(test_PCCollision)
found = localCache.get(dnsQuestion, 0, &key, subnetOut, dnssecOK, receivedOverUDP);
BOOST_CHECK_EQUAL(found, true);
BOOST_REQUIRE(subnetOut);
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.source.toString());
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.getSource().toString());
}

/* now lookup for the same query with a different ECS value,
@@ -843,8 +843,8 @@ BOOST_AUTO_TEST_CASE(test_PCCollision)
pwQ.getHeader()->id = qid;
GenericDNSPacketWriter<PacketBuffer>::optvect_t ednsOptions;
EDNSSubnetOpts opt;
opt.source = Netmask("10.0.167.48/32");
ednsOptions.emplace_back(EDNSOptionCode::ECS, makeEDNSSubnetOptsString(opt));
opt.setSource(Netmask("10.0.167.48/32"));
ednsOptions.emplace_back(EDNSOptionCode::ECS, opt.makeOptString());
pwQ.addOpt(512, 0, 0, ednsOptions);
pwQ.commit();

@@ -855,7 +855,7 @@ BOOST_AUTO_TEST_CASE(test_PCCollision)
BOOST_CHECK_EQUAL(found, false);
BOOST_CHECK_EQUAL(secondKey, key);
BOOST_REQUIRE(subnetOut);
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.source.toString());
BOOST_CHECK_EQUAL(subnetOut->toString(), opt.getSource().toString());
BOOST_CHECK_EQUAL(localCache.getLookupCollisions(), 1U);
}

14 changes: 7 additions & 7 deletions pdns/dnspacket.cc
Original file line number Diff line number Diff line change
@@ -325,7 +325,7 @@ void DNSPacket::wrapup(bool throwsOnTruncation)
{
// this is an upper bound
optsize += EDNS_OPTION_CODE_SIZE + EDNS_OPTION_LENGTH_SIZE + 2 + 1 + 1; // code+len+family+src len+scope len
optsize += d_eso.source.isIPv4() ? 4 : 16;
optsize += d_eso.getSource().isIPv4() ? 4 : 16;
}

if (d_haveednscookie) {
@@ -371,10 +371,10 @@ void DNSPacket::wrapup(bool throwsOnTruncation)
if(d_haveednssubnet) {
EDNSSubnetOpts eso = d_eso;
// use the scopeMask from the resolver, if it is greater - issue #5469
maxScopeMask = max(maxScopeMask, eso.scope.getBits());
eso.scope = Netmask(eso.source.getNetwork(), maxScopeMask);
maxScopeMask = max(maxScopeMask, eso.getScopePrefixLength());
eso.setScopePrefixLength(maxScopeMask);

string opt = makeEDNSSubnetOptsString(eso);
string opt = eso.makeOptString();
opts.emplace_back(8, opt); // 'EDNS SUBNET'
}

@@ -617,7 +617,7 @@ try
d_wantsnsid=true;
}
else if(s_doEDNSSubnetProcessing && (option.first == EDNSOptionCode::ECS)) { // 'EDNS SUBNET'
if(getEDNSSubnetOptsFromString(option.second, &d_eso)) {
if (EDNSSubnetOpts::getFromString(option.second, &d_eso)) {
//cerr<<"Parsed, source: "<<d_eso.source.toString()<<", scope: "<<d_eso.scope.toString()<<", family = "<<d_eso.scope.getNetwork().sin4.sin_family<<endl;
d_haveednssubnet=true;
}
@@ -716,13 +716,13 @@ bool DNSPacket::hasValidEDNSCookie() const
}

void DNSPacket::setRealRemote(const Netmask& netmask) {
d_eso.source = netmask;
d_eso.setSource(netmask);
d_haveednssubnet = true;
}

Netmask DNSPacket::getRealRemote() const
{
return d_haveednssubnet ? d_eso.source : Netmask{getInnerRemote()};
return d_haveednssubnet ? d_eso.getSource() : Netmask{getInnerRemote()};
}

void DNSPacket::setSocket(Utility::sock_t sock)
Loading

0 comments on commit 82933fa

Please sign in to comment.