diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 05bd1393ef..9710b4067d 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -87,7 +87,7 @@ dependencies { api("com.google.firebase:firebase-config-ktx:19.1.4") api("com.google.firebase:firebase-crashlytics:17.0.0") api("com.jakewharton.timber:timber:4.7.1") - api("dnsjava:dnsjava:3.0.2") + api("dnsjava:dnsjava:3.1.0") api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion") api("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:$coroutinesVersion") kapt("androidx.room:room-compiler:$roomVersion") diff --git a/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt b/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt index 203cd532cc..fe3d1c4a44 100644 --- a/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt +++ b/core/src/main/java/com/github/shadowsocks/net/DnsResolverCompat.kt @@ -70,6 +70,7 @@ sealed class DnsResolverCompat { fun prepareDnsResponse(request: Message) = Message(request.header.id).apply { header.setFlag(Flags.QR.toInt()) // this is a response + header.setFlag(Flags.RA.toInt()) // recursion available if (request.header.getFlag(Flags.RD.toInt())) header.setFlag(Flags.RD.toInt()) request.question?.also { addRecord(it, Section.QUESTION) } } @@ -135,11 +136,22 @@ sealed class DnsResolverCompat { val isIpv6 = when (val type = question?.type) { Type.A -> false Type.AAAA -> true + Type.PTR -> { + val ip = try { + // Android does not provide a PTR lookup API for Network prior to Android 10 + ReverseMap.fromName(question.name) + } catch (e: IOException) { + throw UnsupportedOperationException(e) // unrecognized PTR name + } + val hostname = Name.fromString(GlobalScope.async(unboundedIO) { ip.hostName }.await()) + return prepareDnsResponse(request).apply { + addRecord(PTRRecord(question.name, DClass.IN, TTL, hostname), Section.ANSWER) + }.toWire() + } else -> throw UnsupportedOperationException("Unsupported query type $type") } val host = question.name.canonicalize().toString(true) return prepareDnsResponse(request).apply { - header.setFlag(Flags.RA.toInt()) // recursion available for (address in hostResolver(host).asIterable().run { if (isIpv6) filterIsInstance() else filterIsInstance() }) addRecord(when (address) { diff --git a/core/src/main/rust/shadowsocks-rust b/core/src/main/rust/shadowsocks-rust index ea24418ffc..ce1e58641d 160000 --- a/core/src/main/rust/shadowsocks-rust +++ b/core/src/main/rust/shadowsocks-rust @@ -1 +1 @@ -Subproject commit ea24418ffcbb01ebb88fd3af9e161a5f93fe0a27 +Subproject commit ce1e58641d502ec128806efa898ebf2716461132 diff --git a/mobile/build.gradle.kts b/mobile/build.gradle.kts index a3f9d838d1..a13fb0c2c8 100644 --- a/mobile/build.gradle.kts +++ b/mobile/build.gradle.kts @@ -14,7 +14,7 @@ androidExtensions.isExperimental = true dependencies { implementation("androidx.browser:browser:1.2.0") - implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta5") + implementation("androidx.constraintlayout:constraintlayout:2.0.0-beta6") implementation("androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion") implementation("com.google.android.gms:play-services-vision:20.0.0") implementation("com.google.firebase:firebase-ads:19.1.0")