Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
com.ccwangluo.accelerator
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sheteng
com.ccwangluo.accelerator
Commits
d3bedfb5
Commit
d3bedfb5
authored
Jul 13, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Wrap DnsException to simplify handling logic
parent
fee883d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
6 deletions
+4
-6
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
.../main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
+2
-1
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+2
-5
No files found.
core/src/main/java/com/github/shadowsocks/bg/DnsResolverCompat.kt
View file @
d3bedfb5
...
...
@@ -30,6 +30,7 @@ import kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.async
import
kotlinx.coroutines.suspendCancellableCoroutine
import
java.io.IOException
import
java.net.InetAddress
import
java.util.concurrent.Executor
import
kotlin.coroutines.resume
...
...
@@ -69,7 +70,7 @@ sealed class DnsResolverCompat {
signal
,
object
:
DnsResolver
.
Callback
<
Collection
<
InetAddress
>>
{
override
fun
onAnswer
(
answer
:
Collection
<
InetAddress
>,
rcode
:
Int
)
=
cont
.
resume
(
answer
.
toTypedArray
())
override
fun
onError
(
error
:
DnsResolver
.
DnsException
)
=
cont
.
resumeWithException
(
error
)
override
fun
onError
(
error
:
DnsResolver
.
DnsException
)
=
cont
.
resumeWithException
(
IOException
(
error
)
)
})
}
}
...
...
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
d3bedfb5
...
...
@@ -20,8 +20,6 @@
package
com.github.shadowsocks.net
import
android.net.DnsResolver
import
android.os.Build
import
android.util.Log
import
com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.utils.printLog
...
...
@@ -144,9 +142,8 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
when
(
e
)
{
is
TimeoutCancellationException
->
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
"Remote resolving timed out"
)
is
CancellationException
->
{
}
// ignore
else
->
if
(
e
is
IOException
||
Build
.
VERSION
.
SDK_INT
>=
29
&&
e
is
DnsResolver
.
DnsException
)
{
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
e
.
message
)
}
else
printLog
(
e
)
is
IOException
->
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
e
.
message
)
else
->
printLog
(
e
)
}
ByteBuffer
.
wrap
(
prepareDnsResponse
(
request
).
apply
{
header
.
rcode
=
Rcode
.
SERVFAIL
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment