Skip to content

Add EchAwareDns for Android 37#9596

Open
yschimke wants to merge 5 commits into
lysine-dev:masterfrom
yschimke:network_security_policy
Open

Add EchAwareDns for Android 37#9596
yschimke wants to merge 5 commits into
lysine-dev:masterfrom
yschimke:network_security_policy

Conversation

@yschimke

@yschimke yschimke commented Jul 25, 2026

Copy link
Copy Markdown
Collaborator

Adds EchAwareDns which reads the API 37 NetworkSecurityPolicy and decides how to handle Dns depending on domain encryption per hostname (ECH).

@yschimke
yschimke requested a review from swankjesse July 25, 2026 20:56

@swankjesse swankjesse left a comment

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.

Rad!

Comment thread okhttp/build.gradle.kts
allJvmArgs = allJvmArgs.filter { !it.startsWith("--add-opens") }
} else {
// Robolectric's FileDescriptor interceptor reaches into jdk.internal.access, which isn't
// exported to the unnamed module. Android 17 (API 37) images hit it on startup.

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.

Great comment

@SuppressSignatureCheck
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [37], shadows = [ShadowNetworkSecurityPolicy::class])
class EchAwareDnsTest {

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.

Excellent

val records = echAwareDns(newNetworkSecurityPolicy()).recordsFor("publicobject.com")

assertThat(records.addresses()).containsExactly(addressOnlyAddress)
assertThat(records.echConfigLists()).isEmpty()

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.

Neat

internal var cookieJar: CookieJar = CookieJar.NO_COOKIES
internal var cache: Cache? = null
internal var dns: Dns = Dns.SYSTEM
internal var dns: Dns = Platform.get().platformDns()

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 think we should actually change Dns.System to do 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.

I'm not sure, I think of Dns.SYSTEM as InetAddress.getAllByName(hostname)

And it's a field so awkward with lazy init.

    /**
     * A DNS that uses [InetAddress.getAllByName] to ask the underlying operating system to
     * lookup IP addresses. Most custom [Dns] implementations should delegate to this instance.
     */
    @JvmField
    val SYSTEM: Dns = DnsSystem()

@yschimke yschimke changed the title Add EchAwareDns as the default on Android 37 Add EchAwareDns for Android 37 Jul 25, 2026
@yschimke
yschimke marked this pull request as ready for review July 25, 2026 21:51
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.

2 participants