* Fold EchAwareDns into AndroidDns
I don't think each DNS feature should be its own DNS class; instead the single
DNS implementation should be configurable.
None of these classes have shipped in a stable release, so there's no risk
of breaking backwards-compatibility.
* Track changes in EchClientTest
The default cache size is 1,000, which is effectively unbounded
for mobile apps, which likely call a few dozen API servers, ad
networks, and analytics systems.
I don't expect DnsOverHttps to be deployed in other environments.
If so, it's possible this cache will be problematic, as even
10-second stale results can be problematic for server
environments. I'll put an appropriate warning about this in our
release notes.
I had attempted to avoid making StateMachineDnsCall have its own
TaskRunner, instead relying exclusively on the DnsQuery callback
for concurrency. This was more complexity than it was worth, and
it interacted awkwardly with the cache.
Now the DnsOverHttps DnsQuery enforces this invariant, and the
adjacent code is simpler because of it.
* Rearrange new DNS classes without changing behavior
Transport is now DnsQuery.Factory
CachingTransport is now DnsCache
StateMachineDnsCall.Query is now DnsQuery
This is intended to make it possible to have end-users get a DnsCache
instance without being exposed to the implementation details of our
transports and things.
* Use has-a, not is-a for the MemoryCache
* Update AndroidDns
* Track a test API change
* spotless
* More tests for the new DNS cache
* Spotless
* Rename DnsCallStateMachine to StateMachineDnsCall (#9582)
It's no longer necessary to have both the call and the state machine,
the state machine can implement Dns.Call directly.
* Switch to Question as the Transport argument
It makes caching easier.
* New CachingTransport
* spotless
* Switch to ComparableTimeSource
* Switch from computeIfAbsent to putIfAbsent
The former isn't available on API 21.
* Split the state machine out of DnsOverHttps
There's a few things that are a bit awkward, but overall it seems
like it'll afford swapping in UDP or Android's resolver.
* Fixup exception text
* Spotless
* Implement Dns.lookup on Dns.newCall for DnsOverHttps
The lookup path is no longer exercised by OkHttp itself.
This reduces potential drift between the two strategies.
* Spotless
* Update okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsOverHttpsTest.kt
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
---------
Co-authored-by: Yuri Schimke <yuri@schimke.ee>
* Rename includeHttps to includeServiceMetadata
'HTTPS' is way too confusing for DnsOverHttps, because it's about
a DNS record type and not the transport for which records are
retrieved.
* Fix another includeHttps use
* Start including ECH data in RouteSelector results
This changes RouteSelector to use our new async API, when it is
available.
* Extract the execute() function
* Fixup Https results to use targetName
* Fixup some tests
* Use LinkedBlockingQueue instead of CompletableFuture
CompletableFuture isn't available until Android API 24
* Add ECH service metadata to Route.
Also combine DnsOverHttpsServer with FakeDns, so we can serve metadata
anywhere we're testing DNS.
Also move stuff to the 'internal' package in okhttp-dnsoverhttps, so we
can make symbols visible to the main okhttp module's tests.
* Fixup tests
* Test DNS returning zero results
* New tests for HTTPS records
* Honor resolvePrivateAddresses and resolvePublicAddresses in DnsOverHttps
* Spotless
* Test canceling after a partial success
* Use a volatile to track whether it's canceled
* Spotless
* Change how we test DnsOverHttps
Rather than returning opaque hard-coded response bodies, use our
new message encoder so we can test with real value objects.
* Fixup internal API
The first half is EventListenerAdapter, which mechanically
converts event function calls and emits event objects.
The second half is EventRecorder, which validates that the
right events are published.
This is in preparation for a follow-up where I intend
to dynamically add EventListeners to a Call.
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* New @StartStop extension for JUnit 5
This is a new take on our JUnit 5 extension. Rather than creating and managing
the MockWebServer instance in the extension, we let the user create it and all
the extension does is manage the lifecycle.
Note that this annotation doesn't require any external configuration - it doesn't
need a system-property to opt-into 'automatic' extensions, and it doesn't require
a class-level extension either.
* apiDump
* Switch to @StartStop for JUnit 5 tests
* Fixup visibility
---------
Co-authored-by: Jesse Wilson <jwilson@squareup.com>
* Decompose the request line into individual properties
Replace the 'path' property with the URL's encodedPath
property.
Rename the 'requestUrl' property to 'url'.
* Spotless
* Fix up DnsOverHttpsTest
* Fix some test failures
* Simplify the logic.
Rely on OkHttpClient caching, instead of a cache only request.
* Simplify the logic.
Rely on OkHttpClient caching, instead of a cache only request.