Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) LibDNS: Let's make >90% of the websites fail to resolve because dnssec #3883

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

alimpfard
Copy link
Contributor

obviously needs cleanup, more chrome wiring, and some more cleanup.

alimpfard added 11 commits March 9, 2025 13:53
finally, we can verify things; next up: chains!
Previously this function's return value was not reliable, as available
data on the underlying socket did not necessarily translate to available
application data on the TLS socket.
This commit makes it so this function only returns true when we actually
have data buffered and/or available.
Copy link
Contributor

@Hendiadyoin1 Hendiadyoin1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Random stuff I saw

Comment on lines +1101 to +1102
key_tag += (bit_cast<u16>(NetworkOrdered<u16>(flags)) & 0xff) << 8;
key_tag += (bit_cast<u16>(NetworkOrdered<u16>(flags)) >> 8) & 0xff;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would a bit_cast<NetworkOrdered<u16>>(flags) & 0xff << 8 work as well?
Not sure which is more idiomatic and or what is actually meant to happen here, especially as flags is read as network ordered and directly converted.
Note that Endian allows for implicit conversion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that could actually just be convert_between_host_and_blahblah, should do that.

Comment on lines 1103 to +1106
auto protocol = TRY(ctx.stream.read_value<u8>());
key_tag += static_cast<u16>(protocol) << 8;
auto algorithm = static_cast<DNSSEC::Algorithm>(static_cast<u8>(TRY(ctx.stream.read_value<u8>())));
key_tag += static_cast<u16>(algorithm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could replace the autos with explicit types here.
(or even hope that << coerces to int, which I am not sure about)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They're used later with the deduced type, can't really change the variable types like that without adding an extra static_cast later.

Comment on lines 1107 to +1108
auto public_key = TRY(ctx.stream.read_until_eof());
return Records::DNSKEY { flags, protocol, algorithm, move(public_key) };
for (size_t i = 0; i < public_key.size(); ++i) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be odd-sized?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly? Not sure

Comment on lines +1176 to +1177
TRY(stream.write_value(static_cast<u8>(algorithm)));
TRY(stream.write_value(static_cast<u8>(digest_type)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the enums are properly sized this should be able to take them without casts

Comment on lines +1046 to +1050
TRY(stream.write_value(static_cast<NetworkOrdered<u32>>(serial)));
TRY(stream.write_value(static_cast<NetworkOrdered<u32>>(refresh)));
TRY(stream.write_value(static_cast<NetworkOrdered<u32>>(retry)));
TRY(stream.write_value(static_cast<NetworkOrdered<u32>>(expire)));
TRY(stream.write_value(static_cast<NetworkOrdered<u32>>(minimum)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't these static_casts just call the normal constructor?
so you could shorten this quite a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah it calls the ctor, sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants