Skip to content

Write our own DNS message reader#9541

Merged
swankjesse merged 4 commits into
masterfrom
jwilson.0713.dns_message_reader
Jul 14, 2026
Merged

Write our own DNS message reader#9541
swankjesse merged 4 commits into
masterfrom
jwilson.0713.dns_message_reader

Conversation

@swankjesse

Copy link
Copy Markdown
Collaborator

No description provided.

@swankjesse

Copy link
Copy Markdown
Collaborator Author

I want to add support for HTTPS records. I decided it would be better to start fresh vs. building upon our existing DnsRecordCodec class.

Comment thread okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsMessageReader.kt Outdated
Comment thread okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsMessageReader.kt Outdated
val responseCode: Int
get() = (flags and 0b0000_0000_0000_1111)

// Avoid Short.hashCode(short) which isn't available on Android 5.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You'd have to be using an 8-year-old version of AGP to not get this automatically desugared by D8/R8: https://r8.googlesource.com/r8/+/516a6684f134d06eff08080e7ef7129517071817

@swankjesse swankjesse Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I’ll follow-up to fix our Animal Sniffer config, which doesn’t know that R8 can do stuff like this

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@get:JvmName("post") val post: Boolean,
@get:JvmName("resolvePrivateAddresses") val resolvePrivateAddresses: Boolean,
@get:JvmName("resolvePublicAddresses") val resolvePublicAddresses: Boolean,
) : Dns {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I guess this one is stuck on Dns forever, but maybe it can just call the Dns2 impl?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

No, I want this to implement Dns2 ASAP

}

val responseBytes = body.source().readByteString()
val dnsResponse = DnsMessageReader(body.source()).read()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nice

@swankjesse
swankjesse merged commit 37b3a95 into master Jul 14, 2026
28 checks passed
@swankjesse
swankjesse deleted the jwilson.0713.dns_message_reader branch July 14, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants