Skip to content

Commit c7c53b5

Browse files
committed
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.
1 parent 6d0e76d commit c7c53b5

22 files changed

Lines changed: 279 additions & 249 deletions

File tree

build-logic/src/main/kotlin/okhttp.jvm-conventions.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ tasks.withType<KotlinCompile> {
4444
"-Xjvm-default=all",
4545
"-Xexpect-actual-classes",
4646
)
47+
optIn.add("okhttp3.internal.OkHttpInternalApi")
4748
}
4849
}
4950

build-logic/src/main/kotlin/okhttp.publish-conventions.gradle.kts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,12 @@ configure<MavenPublishBaseExtension> {
6464
}
6565

6666
configure<ApiValidationExtension> {
67-
ignoredPackages += "okhttp3.logging.internal"
6867
ignoredPackages += "mockwebserver3.internal"
69-
ignoredPackages += "okhttp3.internal"
7068
ignoredPackages += "mockwebserver3.junit5.internal"
7169
ignoredPackages += "okhttp3.brotli.internal"
70+
ignoredPackages += "okhttp3.dnsoverhttps.internal"
71+
ignoredPackages += "okhttp3.internal"
72+
ignoredPackages += "okhttp3.logging.internal"
7273
ignoredPackages += "okhttp3.sse.internal"
7374
ignoredPackages += "okhttp3.tls.internal"
7475
}

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/DnsOverHttps.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ import okhttp3.MediaType.Companion.toMediaType
2828
import okhttp3.OkHttpClient
2929
import okhttp3.Request
3030
import okhttp3.Response
31+
import okhttp3.dnsoverhttps.internal.DnsMessage
32+
import okhttp3.dnsoverhttps.internal.DnsOverHttpsCall
33+
import okhttp3.dnsoverhttps.internal.QueryRequestBody
34+
import okhttp3.dnsoverhttps.internal.ResourceRecord
35+
import okhttp3.dnsoverhttps.internal.TYPE_A
36+
import okhttp3.dnsoverhttps.internal.TYPE_AAAA
37+
import okhttp3.dnsoverhttps.internal.TYPE_HTTPS
38+
import okhttp3.dnsoverhttps.internal.asQueryParameter
39+
import okhttp3.dnsoverhttps.internal.decodeResponse
3140
import okhttp3.internal.publicsuffix.PublicSuffixDatabase
3241

3342
/**

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsMessage.kt renamed to okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/internal/-DnsMessage.kt

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
@file:Suppress("ktlint:standard:filename")
1717

18-
package okhttp3.dnsoverhttps
18+
package okhttp3.dnsoverhttps.internal
1919

2020
import java.io.IOException
2121
import java.net.InetAddress
@@ -26,12 +26,14 @@ import okhttp3.RequestBody
2626
import okhttp3.Response
2727
import okhttp3.dnsoverhttps.DnsOverHttps.Companion.DNS_MESSAGE
2828
import okhttp3.dnsoverhttps.DnsOverHttps.Companion.MAX_RESPONSE_SIZE
29+
import okhttp3.internal.OkHttpInternalApi
2930
import okhttp3.internal.platform.Platform
3031
import okio.Buffer
3132
import okio.BufferedSink
3233
import okio.ByteString
3334

34-
internal data class DnsMessage(
35+
@OkHttpInternalApi
36+
data class DnsMessage(
3537
val id: Short,
3638
val flags: Int,
3739
val questions: List<Question>,
@@ -79,7 +81,7 @@ internal data class DnsMessage(
7981
}
8082
}
8183

82-
internal data class Question(
84+
data class Question(
8385
val name: String,
8486
val type: Int,
8587
val `class`: Int = CLASS_IN,
@@ -94,7 +96,7 @@ internal data class Question(
9496
}
9597
}
9698

97-
internal sealed interface ResourceRecord {
99+
sealed interface ResourceRecord {
98100
val name: String
99101
val timeToLive: Int
100102

@@ -140,12 +142,18 @@ internal sealed interface ResourceRecord {
140142
}
141143

142144
/** https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-4 */
143-
internal const val TYPE_A = 1
144-
internal const val TYPE_AAAA = 28
145-
internal const val TYPE_HTTPS = 65
145+
@OkHttpInternalApi
146+
const val TYPE_A = 1
147+
148+
@OkHttpInternalApi
149+
const val TYPE_AAAA = 28
150+
151+
@OkHttpInternalApi
152+
const val TYPE_HTTPS = 65
146153

147154
/** https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-2 */
148-
internal const val CLASS_IN = 1
155+
@OkHttpInternalApi
156+
const val CLASS_IN = 1
149157

150158
/** https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-6 */
151159
internal const val RESPONSE_CODE_SUCCESS = 0

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsMessageReader.kt renamed to okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/internal/-DnsMessageReader.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
*/
1616
@file:Suppress("ktlint:standard:filename")
1717

18-
package okhttp3.dnsoverhttps
18+
package okhttp3.dnsoverhttps.internal
1919

2020
import java.net.InetAddress
2121
import okhttp3.Protocol
22+
import okhttp3.internal.OkHttpInternalApi
2223
import okio.Buffer
2324
import okio.BufferedSource
2425
import okio.ByteString
@@ -33,7 +34,8 @@ import okio.buffer
3334
*
3435
* https://datatracker.ietf.org/doc/html/rfc1035
3536
*/
36-
internal class DnsMessageReader(
37+
@OkHttpInternalApi
38+
class DnsMessageReader(
3739
source: BufferedSource,
3840
) {
3941
/**

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsMessageWriter.kt renamed to okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/internal/-DnsMessageWriter.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
*/
1616
@file:Suppress("ktlint:standard:filename")
1717

18-
package okhttp3.dnsoverhttps
18+
package okhttp3.dnsoverhttps.internal
1919

2020
import java.net.Inet4Address
2121
import java.net.Inet6Address
2222
import okhttp3.Protocol
23+
import okhttp3.internal.OkHttpInternalApi
2324
import okio.Buffer
2425
import okio.ByteString
2526
import okio.ByteString.Companion.encodeUtf8
@@ -30,7 +31,8 @@ import okio.utf8Size
3031
*
3132
* https://datatracker.ietf.org/doc/html/rfc1035
3233
*/
33-
internal class DnsMessageWriter(
34+
@OkHttpInternalApi
35+
class DnsMessageWriter(
3436
private val sink: Buffer,
3537
) {
3638
/**

okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/-DnsOverHttpsCall.kt renamed to okhttp-dnsoverhttps/src/main/kotlin/okhttp3/dnsoverhttps/internal/-DnsOverHttpsCall.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
* limitations under the License.
1515
*/
1616
@file:Suppress("ktlint:standard:filename")
17-
@file:OptIn(OkHttpInternalApi::class)
1817

19-
package okhttp3.dnsoverhttps
18+
package okhttp3.dnsoverhttps.internal
2019

2120
import java.io.IOException
2221
import java.util.concurrent.atomic.AtomicReference
@@ -35,6 +34,7 @@ import okhttp3.internal.testAndSet
3534
/**
3635
* Implements [Dns.Call] by making multiple HTTPS calls.
3736
*/
37+
@OkHttpInternalApi
3838
internal class DnsOverHttpsCall(
3939
override val request: Dns.Request,
4040
private val calls: List<Call>,

okhttp-dnsoverhttps/src/test/java/okhttp3/dnsoverhttps/DnsOverHttpsServer.kt

Lines changed: 0 additions & 141 deletions
This file was deleted.

0 commit comments

Comments
 (0)