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
45fea940
Commit
45fea940
authored
Jul 05, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use hosts for resolving remote
Fix #2256.
parent
44f37d14
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
20 additions
and
18 deletions
+20
-18
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+7
-8
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
...rc/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
+3
-4
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+4
-2
core/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
.../main/java/com/github/shadowsocks/bg/TransproxyService.kt
+3
-2
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+3
-2
No files found.
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
45fea940
...
...
@@ -36,12 +36,10 @@ import com.github.shadowsocks.aidl.IShadowsocksService
import
com.github.shadowsocks.aidl.IShadowsocksServiceCallback
import
com.github.shadowsocks.aidl.TrafficStats
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.net.HostsFile
import
com.github.shadowsocks.plugin.PluginManager
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Action
import
com.github.shadowsocks.utils.broadcastReceiver
import
com.github.shadowsocks.utils.printLog
import
com.github.shadowsocks.utils.readableMessage
import
com.github.shadowsocks.utils.*
import
com.google.firebase.analytics.FirebaseAnalytics
import
kotlinx.coroutines.*
import
java.io.File
...
...
@@ -232,7 +230,7 @@ object BaseService {
fun
buildAdditionalArguments
(
cmd
:
ArrayList
<
String
>):
ArrayList
<
String
>
=
cmd
suspend
fun
startProcesses
()
{
suspend
fun
startProcesses
(
hosts
:
HostsFile
)
{
val
configRoot
=
(
if
(
Build
.
VERSION
.
SDK_INT
<
24
||
app
.
getSystemService
<
UserManager
>()
?.
isUserUnlocked
!=
false
)
app
else
Core
.
deviceStorage
).
noBackupFilesDir
val
udpFallback
=
data
.
udpFallback
...
...
@@ -343,14 +341,15 @@ object BaseService {
try
{
Executable
.
killAll
()
// clean up old processes
preInit
()
proxy
.
init
(
this
@Interface
)
data
.
udpFallback
?.
init
(
this
@Interface
)
val
hosts
=
HostsFile
(
DataStore
.
publicStore
.
getString
(
Key
.
hosts
)
?:
""
)
proxy
.
init
(
this
@Interface
,
hosts
)
data
.
udpFallback
?.
init
(
this
@Interface
,
hosts
)
data
.
processes
=
GuardedProcessPool
{
printLog
(
it
)
stopRunner
(
false
,
it
.
readableMessage
)
}
startProcesses
()
startProcesses
(
hosts
)
proxy
.
scheduleUpdate
()
data
.
udpFallback
?.
scheduleUpdate
()
...
...
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
View file @
45fea940
...
...
@@ -28,7 +28,6 @@ import com.github.shadowsocks.net.LocalDnsServer
import
com.github.shadowsocks.net.Socks5Endpoint
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Key
import
kotlinx.coroutines.CoroutineScope
import
java.net.InetSocketAddress
import
java.net.URI
...
...
@@ -45,14 +44,14 @@ object LocalDnsService {
private
val
servers
=
WeakHashMap
<
Interface
,
LocalDnsServer
>()
interface
Interface
:
BaseService
.
Interface
{
override
suspend
fun
startProcesses
()
{
super
.
startProcesses
()
override
suspend
fun
startProcesses
(
hosts
:
HostsFile
)
{
super
.
startProcesses
(
hosts
)
val
profile
=
data
.
proxy
!!
.
profile
val
dns
=
URI
(
"dns://${profile.remoteDns}"
)
LocalDnsServer
(
this
::
resolver
,
Socks5Endpoint
(
dns
.
host
,
if
(
dns
.
port
<
0
)
53
else
dns
.
port
),
DataStore
.
proxyAddress
,
HostsFile
(
DataStore
.
publicStore
.
getString
(
Key
.
hosts
)
?:
""
)
).
apply
{
hosts
).
apply
{
tcp
=
!
profile
.
udpdns
when
(
profile
.
route
)
{
Acl
.
BYPASS_CHN
,
Acl
.
BYPASS_LAN_CHN
,
Acl
.
GFWLIST
,
Acl
.
CUSTOM_RULES
->
{
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
45fea940
...
...
@@ -26,6 +26,7 @@ import com.github.shadowsocks.Core
import
com.github.shadowsocks.acl.Acl
import
com.github.shadowsocks.acl.AclSyncer
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.net.HostsFile
import
com.github.shadowsocks.plugin.PluginConfiguration
import
com.github.shadowsocks.plugin.PluginManager
import
com.github.shadowsocks.preference.DataStore
...
...
@@ -51,7 +52,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
val
pluginPath
by
lazy
{
PluginManager
.
init
(
plugin
)
}
private
var
scheduleConfigUpdate
=
false
suspend
fun
init
(
service
:
BaseService
.
Interface
)
{
suspend
fun
init
(
service
:
BaseService
.
Interface
,
hosts
:
HostsFile
)
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
scheduleConfigUpdate
=
true
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
...
...
@@ -85,7 +86,8 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
// it's hard to resolve DNS on a specific interface so we'll do it here
if
(
profile
.
host
.
parseNumericAddress
()
==
null
)
{
profile
.
host
=
service
.
resolver
(
profile
.
host
).
firstOrNull
()
?.
hostAddress
?:
throw
UnknownHostException
()
profile
.
host
=
(
hosts
.
resolve
(
profile
.
host
).
firstOrNull
()
?:
service
.
resolver
(
profile
.
host
).
firstOrNull
())
?.
hostAddress
?:
throw
UnknownHostException
()
}
}
...
...
core/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
View file @
45fea940
...
...
@@ -23,6 +23,7 @@ package com.github.shadowsocks.bg
import
android.app.Service
import
android.content.Intent
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.net.HostsFile
import
com.github.shadowsocks.preference.DataStore
import
java.io.File
...
...
@@ -56,9 +57,9 @@ redsocks {
File
(
applicationInfo
.
nativeLibraryDir
,
Executable
.
REDSOCKS
).
absolutePath
,
"-c"
,
"redsocks.conf"
))
}
override
suspend
fun
startProcesses
()
{
override
suspend
fun
startProcesses
(
hosts
:
HostsFile
)
{
startRedsocksDaemon
()
super
.
startProcesses
()
super
.
startProcesses
(
hosts
)
}
override
fun
onDestroy
()
{
...
...
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
45fea940
...
...
@@ -36,6 +36,7 @@ import com.github.shadowsocks.acl.Acl
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.net.ConcurrentLocalSocketListener
import
com.github.shadowsocks.net.DefaultNetworkListener
import
com.github.shadowsocks.net.HostsFile
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Key
...
...
@@ -142,9 +143,9 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
override
suspend
fun
resolver
(
host
:
String
)
=
DnsResolverCompat
.
resolve
(
DefaultNetworkListener
.
get
(),
host
)
override
suspend
fun
openConnection
(
url
:
URL
)
=
DefaultNetworkListener
.
get
().
openConnection
(
url
)
override
suspend
fun
startProcesses
()
{
override
suspend
fun
startProcesses
(
hosts
:
HostsFile
)
{
worker
=
ProtectWorker
().
apply
{
start
()
}
super
.
startProcesses
()
super
.
startProcesses
(
hosts
)
sendFd
(
startVpn
())
}
...
...
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