Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rgacogne committed Dec 21, 2023
1 parent 79cbb02 commit c58c0f1
Show file tree
Hide file tree
Showing 4 changed files with 202 additions and 122 deletions.
2 changes: 1 addition & 1 deletion pdns/dnsdist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ void responderThread(std::shared_ptr<DownstreamState> dss)

for (const auto& fd : sockets) {
/* allocate one more byte so we can detect truncation */
// NOLINTNEXTLINE(bugprone-use-after-move): resizing a vector has no preconditions so it is valid to do so after moving it
// NOLINTNEXTLINE(bugprone-use-after-move): resizing a vector has no preconditions so it is valid to do so after moving it
response.resize(initialBufferSize + 1);
ssize_t got = recv(fd, response.data(), response.size(), 0);

Expand Down
31 changes: 30 additions & 1 deletion pdns/dnsdistdist/doq-common.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ PacketBuffer mintToken(const PacketBuffer& dcid, const ComboAddress& peer)
return encryptedTokenPacket;
}
catch (const std::exception& exp) {
cerr<<"error while minting token "<<exp.what()<<endl;
vinfolog("Error while minting DoH3 token: %s", exp.what());
throw;
}
Expand Down Expand Up @@ -119,6 +120,7 @@ std::optional<PacketBuffer> validateToken(const PacketBuffer& token, const Combo
return PacketBuffer(plainText.begin() + (sizeof(ttd) + addrBytes.size()), plainText.end());
}
catch (const std::exception& exp) {
cerr<<"error while validating token "<<exp.what()<<endl;
vinfolog("Error while validating DoH3 token: %s", exp.what());
return std::nullopt;
}
Expand All @@ -143,11 +145,21 @@ void handleStatelessRetry(Socket& sock, const PacketBuffer& clientConnID, const

if (written < 0) {
DEBUGLOG("failed to create retry packet " << written);
cerr<<"error while creating retry packet "<<written<<endl;
return;
}
// if (written == 0) {
// return;
// }

out.resize(written);
sock.sendTo(std::string(out.begin(), out.end()), peer);
try {
sock.sendTo(std::string(out.begin(), out.end()), peer);
}
catch (const std::exception& exp) {
cerr<<"error sending retry "<<out.size()<<" to "<<peer.toStringWithPort()<<": "<<exp.what()<<endl;
throw;
}
}

void handleVersionNegociation(Socket& sock, const PacketBuffer& clientConnID, const PacketBuffer& serverConnID, const ComboAddress& peer)
Expand All @@ -160,10 +172,19 @@ void handleVersionNegociation(Socket& sock, const PacketBuffer& clientConnID, co

if (written < 0) {
DEBUGLOG("failed to create vneg packet " << written);
cerr<<"error while creating vneg packet "<<written<<endl;
return;
}
try {

// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
sock.sendTo(reinterpret_cast<const char*>(out.data()), written, peer);
}
catch (const std::exception& exp) {
cerr<<"error sending version neg "<<out.size()<<" to "<<peer.toStringWithPort()<<": "<<exp.what()<<endl;
throw;
}

}

void flushEgress(Socket& sock, QuicheConnection& conn, const ComboAddress& peer)
Expand All @@ -178,11 +199,19 @@ void flushEgress(Socket& sock, QuicheConnection& conn, const ComboAddress& peer)
}

if (written < 0) {
cerr<<"error while sending egress packet "<<written<<endl;
return;
}
// FIXME pacing (as send_info.at should tell us when to send the packet) ?
try {
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast)
sock.sendTo(reinterpret_cast<const char*>(out.data()), written, peer);
}
catch (const std::exception& exp) {
cerr<<"error sending egress "<<written<<" to "<<peer.toStringWithPort()<<": "<<exp.what()<<endl;
throw;
}

}
}

Expand Down
Loading

0 comments on commit c58c0f1

Please sign in to comment.