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
6570c098
Commit
6570c098
authored
Feb 08, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Log remote resolving time out
parent
6b9f2245
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+9
-3
No files found.
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
6570c098
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
package
com.github.shadowsocks.net
package
com.github.shadowsocks.net
import
android.util.Log
import
android.util.Log
import
com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.utils.printLog
import
com.github.shadowsocks.utils.printLog
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
import
org.xbill.DNS.*
import
org.xbill.DNS.*
...
@@ -54,6 +55,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -54,6 +55,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
var
localIpMatcher
:
List
<
Subnet
>
=
emptyList
()
var
localIpMatcher
:
List
<
Subnet
>
=
emptyList
()
companion
object
{
companion
object
{
private
const
val
TAG
=
"LocalDnsServer"
private
const
val
TIMEOUT
=
10_000L
private
const
val
TIMEOUT
=
10_000L
/**
/**
* TTL returned from localResolver is set to 120. Android API does not provide TTL,
* TTL returned from localResolver is set to 120. Android API does not provide TTL,
...
@@ -107,7 +109,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -107,7 +109,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
val
localResults
=
try
{
val
localResults
=
try
{
withTimeout
(
TIMEOUT
)
{
GlobalScope
.
async
(
Dispatchers
.
IO
)
{
localResolver
(
host
)
}.
await
()
}
withTimeout
(
TIMEOUT
)
{
GlobalScope
.
async
(
Dispatchers
.
IO
)
{
localResolver
(
host
)
}.
await
()
}
}
catch
(
_
:
TimeoutCancellationException
)
{
}
catch
(
_
:
TimeoutCancellationException
)
{
Log
.
w
(
"LocalDnsServer"
,
"Local resolving timed out, falling back to remote resolving"
)
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
"Local resolving timed out, falling back to remote resolving"
)
return
@coroutineScope
remote
.
await
()
return
@coroutineScope
remote
.
await
()
}
catch
(
_
:
UnknownHostException
)
{
}
catch
(
_
:
UnknownHostException
)
{
return
@coroutineScope
remote
.
await
()
return
@coroutineScope
remote
.
await
()
...
@@ -124,9 +126,13 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -124,9 +126,13 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
},
Section
.
ANSWER
)
},
Section
.
ANSWER
)
}.
toWire
())
}.
toWire
())
}
else
remote
.
await
()
}
else
remote
.
await
()
}
catch
(
e
:
IO
Exception
)
{
}
catch
(
e
:
Exception
)
{
remote
.
cancel
()
remote
.
cancel
()
printLog
(
e
)
when
(
e
)
{
is
TimeoutCancellationException
->
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
"Remote resolving timed out"
)
is
CancellationException
->
{
}
// ignore
else
->
printLog
(
e
)
}
ByteBuffer
.
wrap
(
prepareDnsResponse
(
request
).
apply
{
ByteBuffer
.
wrap
(
prepareDnsResponse
(
request
).
apply
{
header
.
rcode
=
Rcode
.
SERVFAIL
header
.
rcode
=
Rcode
.
SERVFAIL
}.
toWire
())
}.
toWire
())
...
...
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