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
14f386ca
Commit
14f386ca
authored
Feb 22, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent remote resolving failure kills entire resolver
parent
3e61fdb7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
7 deletions
+7
-7
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+7
-7
No files found.
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
14f386ca
...
@@ -99,23 +99,23 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -99,23 +99,23 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
printLog
(
e
)
printLog
(
e
)
return
forward
(
packet
)
return
forward
(
packet
)
}
}
return
coroutine
Scope
{
return
super
visor
Scope
{
val
remote
=
async
{
withTimeout
(
TIMEOUT
)
{
forward
(
packet
)
}
}
val
remote
=
async
{
withTimeout
(
TIMEOUT
)
{
forward
(
packet
)
}
}
try
{
try
{
if
(
forwardOnly
||
request
.
header
.
opcode
!=
Opcode
.
QUERY
)
return
@
coroutine
Scope
remote
.
await
()
if
(
forwardOnly
||
request
.
header
.
opcode
!=
Opcode
.
QUERY
)
return
@
supervisor
Scope
remote
.
await
()
val
question
=
request
.
question
val
question
=
request
.
question
if
(
question
?.
type
!=
Type
.
A
)
return
@
coroutine
Scope
remote
.
await
()
if
(
question
?.
type
!=
Type
.
A
)
return
@
supervisor
Scope
remote
.
await
()
val
host
=
question
.
name
.
toString
(
true
)
val
host
=
question
.
name
.
toString
(
true
)
if
(
remoteDomainMatcher
?.
containsMatchIn
(
host
)
==
true
)
return
@
coroutine
Scope
remote
.
await
()
if
(
remoteDomainMatcher
?.
containsMatchIn
(
host
)
==
true
)
return
@
supervisor
Scope
remote
.
await
()
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
)
{
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
"Local resolving timed out, falling back to remote resolving"
)
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
"Local resolving timed out, falling back to remote resolving"
)
return
@
coroutine
Scope
remote
.
await
()
return
@
supervisor
Scope
remote
.
await
()
}
catch
(
_
:
UnknownHostException
)
{
}
catch
(
_
:
UnknownHostException
)
{
return
@
coroutine
Scope
remote
.
await
()
return
@
supervisor
Scope
remote
.
await
()
}
}
if
(
localResults
.
isEmpty
())
return
@
coroutine
Scope
remote
.
await
()
if
(
localResults
.
isEmpty
())
return
@
supervisor
Scope
remote
.
await
()
if
(
localIpMatcher
.
isEmpty
()
||
localIpMatcher
.
any
{
subnet
->
localResults
.
any
(
subnet
::
matches
)
})
{
if
(
localIpMatcher
.
isEmpty
()
||
localIpMatcher
.
any
{
subnet
->
localResults
.
any
(
subnet
::
matches
)
})
{
remote
.
cancel
()
remote
.
cancel
()
ByteBuffer
.
wrap
(
prepareDnsResponse
(
request
).
apply
{
ByteBuffer
.
wrap
(
prepareDnsResponse
(
request
).
apply
{
...
...
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