Commit 44f37d14 authored by Mygod's avatar Mygod

Suppress DnsExceptions

parent 483f1609
...@@ -20,6 +20,8 @@ ...@@ -20,6 +20,8 @@
package com.github.shadowsocks.net package com.github.shadowsocks.net
import android.net.DnsResolver
import android.os.Build
import android.util.Log import android.util.Log
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.github.shadowsocks.utils.printLog import com.github.shadowsocks.utils.printLog
...@@ -142,8 +144,9 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd ...@@ -142,8 +144,9 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
when (e) { when (e) {
is TimeoutCancellationException -> Crashlytics.log(Log.WARN, TAG, "Remote resolving timed out") is TimeoutCancellationException -> Crashlytics.log(Log.WARN, TAG, "Remote resolving timed out")
is CancellationException -> { } // ignore is CancellationException -> { } // ignore
is IOException -> Crashlytics.log(Log.WARN, TAG, e.message) else -> if (e is IOException || Build.VERSION.SDK_INT >= 29 && e is DnsResolver.DnsException) {
else -> printLog(e) Crashlytics.log(Log.WARN, TAG, e.message)
} else printLog(e)
} }
ByteBuffer.wrap(prepareDnsResponse(request).apply { ByteBuffer.wrap(prepareDnsResponse(request).apply {
header.rcode = Rcode.SERVFAIL header.rcode = Rcode.SERVFAIL
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment