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
fd4d7f46
Commit
fd4d7f46
authored
Dec 19, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure to clean up acl
parent
5ca1e2e4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
6 deletions
+8
-6
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
...rc/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
+4
-3
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
...rc/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
+4
-3
No files found.
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
View file @
fd4d7f46
...
@@ -48,9 +48,10 @@ object LocalDnsService {
...
@@ -48,9 +48,10 @@ object LocalDnsService {
Socks5Endpoint
(
dns
.
host
,
if
(
dns
.
port
<
0
)
53
else
dns
.
port
),
Socks5Endpoint
(
dns
.
host
,
if
(
dns
.
port
<
0
)
53
else
dns
.
port
),
DataStore
.
proxyAddress
,
DataStore
.
proxyAddress
,
hosts
,
hosts
,
!
profile
.
udpdns
)
{
!
profile
.
udpdns
,
if
(
profile
.
route
==
Acl
.
ALL
)
null
else
AclMatcher
().
apply
{
init
(
profile
.
route
)
}
if
(
profile
.
route
==
Acl
.
ALL
)
null
else
object
{
}.
also
{
suspend fun create
Acl
()
=
AclMatcher
().
apply
{
init
(
profile
.
route
)
}
}
::
createAcl
).
also
{
servers
[
this
]
=
it
servers
[
this
]
=
it
}.
start
(
InetSocketAddress
(
DataStore
.
listenAddress
,
DataStore
.
portLocalDns
))
}.
start
(
InetSocketAddress
(
DataStore
.
listenAddress
,
DataStore
.
portLocalDns
))
}
}
...
...
core/src/main/java/com/github/shadowsocks/net/LocalDnsServer.kt
View file @
fd4d7f46
...
@@ -51,7 +51,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -51,7 +51,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
* Forward UDP queries to TCP.
* Forward UDP queries to TCP.
*/
*/
private
val
tcp
:
Boolean
=
false
,
private
val
tcp
:
Boolean
=
false
,
private
val
aclSpawn
:
suspend
()
->
AclMatcher
?
=
{
null
}
)
:
CoroutineScope
{
aclSpawn
:
(
suspend
()
->
AclMatcher
)?
=
null
)
:
CoroutineScope
{
companion
object
{
companion
object
{
private
const
val
TAG
=
"LocalDnsServer"
private
const
val
TAG
=
"LocalDnsServer"
private
const
val
TIMEOUT
=
10_000L
private
const
val
TIMEOUT
=
10_000L
...
@@ -84,7 +84,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -84,7 +84,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
override
val
coroutineContext
=
SupervisorJob
()
+
CoroutineExceptionHandler
{
_
,
t
->
override
val
coroutineContext
=
SupervisorJob
()
+
CoroutineExceptionHandler
{
_
,
t
->
if
(
t
is
IOException
)
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
t
.
message
)
else
printLog
(
t
)
if
(
t
is
IOException
)
Crashlytics
.
log
(
Log
.
WARN
,
TAG
,
t
.
message
)
else
printLog
(
t
)
}
}
private
val
acl
=
a
sync
{
aclSpawn
()
}
private
val
acl
=
a
clSpawn
?.
let
{
async
{
it
()
}
}
suspend
fun
start
(
listen
:
SocketAddress
)
=
DatagramChannel
.
open
().
run
{
suspend
fun
start
(
listen
:
SocketAddress
)
=
DatagramChannel
.
open
().
run
{
configureBlocking
(
false
)
configureBlocking
(
false
)
...
@@ -129,7 +129,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -129,7 +129,7 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
remote
.
cancel
()
remote
.
cancel
()
return
@supervisorScope
cookDnsResponse
(
request
,
hostsResults
)
return
@supervisorScope
cookDnsResponse
(
request
,
hostsResults
)
}
}
val
acl
=
acl
.
await
()
?:
return
@supervisorScope
remote
.
await
()
val
acl
=
acl
?
.
await
()
?:
return
@supervisorScope
remote
.
await
()
val
useLocal
=
when
(
acl
.
shouldBypass
(
host
))
{
val
useLocal
=
when
(
acl
.
shouldBypass
(
host
))
{
true
->
true
.
also
{
remote
.
cancel
()
}
true
->
true
.
also
{
remote
.
cancel
()
}
false
->
return
@supervisorScope
remote
.
await
()
false
->
return
@supervisorScope
remote
.
await
()
...
@@ -204,5 +204,6 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
...
@@ -204,5 +204,6 @@ class LocalDnsServer(private val localResolver: suspend (String) -> Array<InetAd
cancel
()
cancel
()
monitor
.
close
(
scope
)
monitor
.
close
(
scope
)
coroutineContext
[
Job
]
!!
.
also
{
job
->
scope
.
launch
{
job
.
join
()
}
}
coroutineContext
[
Job
]
!!
.
also
{
job
->
scope
.
launch
{
job
.
join
()
}
}
acl
?.
also
{
scope
.
launch
{
it
.
await
().
close
()
}
}
}
}
}
}
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