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
8e3d20b6
Commit
8e3d20b6
authored
Mar 14, 2021
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refine the JSON config file for ss-rust 1.10
parent
c2a6c8a4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
18 deletions
+42
-18
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+2
-2
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+39
-15
core/src/main/rust/shadowsocks-rust
core/src/main/rust/shadowsocks-rust
+1
-1
No files found.
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
8e3d20b6
...
@@ -246,13 +246,13 @@ object BaseService {
...
@@ -246,13 +246,13 @@ object BaseService {
data
.
proxy
!!
.
start
(
this
,
data
.
proxy
!!
.
start
(
this
,
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"stat_main"
),
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"stat_main"
),
File
(
configRoot
,
CONFIG_FILE
),
File
(
configRoot
,
CONFIG_FILE
),
if
(
udpFallback
==
null
&&
data
.
proxy
?.
plugin
==
null
)
"
-U"
else
null
)
if
(
udpFallback
==
null
&&
data
.
proxy
?.
plugin
==
null
)
"
tcp_and_udp"
else
"tcp_only"
)
if
(
udpFallback
?.
plugin
!=
null
)
throw
ExpectedExceptionWrapper
(
IllegalStateException
(
if
(
udpFallback
?.
plugin
!=
null
)
throw
ExpectedExceptionWrapper
(
IllegalStateException
(
"UDP fallback cannot have plugins"
))
"UDP fallback cannot have plugins"
))
udpFallback
?.
start
(
this
,
udpFallback
?.
start
(
this
,
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"stat_udp"
),
File
(
Core
.
deviceStorage
.
noBackupFilesDir
,
"stat_udp"
),
File
(
configRoot
,
CONFIG_FILE_UDP
),
File
(
configRoot
,
CONFIG_FILE_UDP
),
"
-u
"
,
false
)
"
udp_only
"
,
false
)
data
.
localDns
=
LocalDnsWorker
(
this
::
rawResolver
).
apply
{
start
()
}
data
.
localDns
=
LocalDnsWorker
(
this
::
rawResolver
).
apply
{
start
()
}
}
}
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
8e3d20b6
...
@@ -30,6 +30,7 @@ import com.github.shadowsocks.preference.DataStore
...
@@ -30,6 +30,7 @@ import com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.parseNumericAddress
import
kotlinx.coroutines.CoroutineScope
import
kotlinx.coroutines.CoroutineScope
import
org.json.JSONArray
import
org.json.JSONArray
import
org.json.JSONObject
import
java.io.File
import
java.io.File
import
java.io.IOException
import
java.io.IOException
import
java.net.URI
import
java.net.URI
...
@@ -68,10 +69,13 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -68,10 +69,13 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
* Sensitive shadowsocks configuration file requires extra protection. It may be stored in encrypted storage or
* Sensitive shadowsocks configuration file requires extra protection. It may be stored in encrypted storage or
* device storage, depending on which is currently available.
* device storage, depending on which is currently available.
*/
*/
fun
start
(
service
:
BaseService
.
Interface
,
stat
:
File
,
configFile
:
File
,
extraFlag
:
String
?
=
null
,
fun
start
(
service
:
BaseService
.
Interface
,
stat
:
File
,
configFile
:
File
,
mode
:
String
,
dnsRelay
:
Boolean
=
true
)
{
dnsRelay
:
Boolean
=
true
)
{
// setup traffic monitor path
trafficMonitor
=
TrafficMonitor
(
stat
)
trafficMonitor
=
TrafficMonitor
(
stat
)
// init JSON config
this
.
configFile
=
configFile
this
.
configFile
=
configFile
val
config
=
profile
.
toJson
()
val
config
=
profile
.
toJson
()
plugin
?.
let
{
(
path
,
opts
,
isV2
)
->
plugin
?.
let
{
(
path
,
opts
,
isV2
)
->
...
@@ -80,29 +84,49 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -80,29 +84,49 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
}
}
config
.
put
(
"plugin"
,
path
).
put
(
"plugin_opts"
,
opts
.
toString
())
config
.
put
(
"plugin"
,
path
).
put
(
"plugin_opts"
,
opts
.
toString
())
}
}
config
.
put
(
"local_address"
,
DataStore
.
listenAddress
)
config
.
put
(
"local_port"
,
DataStore
.
portProxy
)
config
.
put
(
"udp_max_associations"
,
256
)
config
.
put
(
"udp_max_associations"
,
256
)
config
.
put
(
"dns"
,
"unix://local_dns_path"
)
// init local config array
val
localConfigs
=
JSONArray
()
// local SOCKS5 proxy
val
proxyConfig
=
JSONObject
()
proxyConfig
.
put
(
"local_address"
,
"${DataStore.listenAddress}"
)
proxyConfig
.
put
(
"local_port"
,
DataStore
.
portProxy
)
proxyConfig
.
put
(
"local_udp_address"
,
"${DataStore.listenAddress}"
)
proxyConfig
.
put
(
"local_udp_port"
,
DataStore
.
portProxy
)
proxyConfig
.
put
(
"mode"
,
mode
)
localConfigs
.
put
(
proxyConfig
)
// local DNS proxy
if
(
dnsRelay
)
try
{
URI
(
"dns://${profile.remoteDns}"
)
}
catch
(
e
:
URISyntaxException
)
{
throw
BaseService
.
ExpectedExceptionWrapper
(
e
)
}.
let
{
dns
->
val
dnsConfig
=
JSONObject
()
dnsConfig
.
put
(
"local_address"
,
"${DataStore.listenAddress}"
)
dnsConfig
.
put
(
"local_port"
,
DataStore
.
portLocalDns
)
dnsConfig
.
put
(
"local_dns_address"
,
"local_dns_path"
)
dnsConfig
.
put
(
"remote_dns_address"
,
"${dns.host ?: "
0.0.0.0
"}"
)
dnsConfig
.
put
(
"remote_dns_port"
,
if
(
dns
.
port
<
0
)
53
else
dns
.
port
)
dnsConfig
.
put
(
"protocol"
,
"dns"
)
localConfigs
.
put
(
dnsConfig
)
}
// add all the locals
config
.
put
(
"locals"
,
localConfigs
)
configFile
.
writeText
(
config
.
toString
())
configFile
.
writeText
(
config
.
toString
())
// build the command line
val
cmd
=
arrayListOf
(
val
cmd
=
arrayListOf
(
File
((
service
as
Context
).
applicationInfo
.
nativeLibraryDir
,
Executable
.
SS_LOCAL
).
absolutePath
,
File
((
service
as
Context
).
applicationInfo
.
nativeLibraryDir
,
Executable
.
SS_LOCAL
).
absolutePath
,
"--stat-path"
,
stat
.
absolutePath
,
"--stat-path"
,
stat
.
absolutePath
,
"-c"
,
configFile
.
absolutePath
,
"-c"
,
configFile
.
absolutePath
,
"--udp-bind-addr"
,
"${DataStore.listenAddress}:${DataStore.portProxy}"
,
)
)
if
(
service
.
isVpnService
)
cmd
+=
arrayListOf
(
"--vpn"
)
if
(
service
.
isVpnService
)
cmd
+=
arrayListOf
(
"--vpn"
)
if
(
extraFlag
!=
null
)
cmd
.
add
(
extraFlag
)
if
(
dnsRelay
)
try
{
URI
(
"dns://${profile.remoteDns}"
)
}
catch
(
e
:
URISyntaxException
)
{
throw
BaseService
.
ExpectedExceptionWrapper
(
e
)
}.
let
{
dns
->
cmd
+=
arrayListOf
(
"--dns-addr"
,
"${DataStore.listenAddress}:${DataStore.portLocalDns}"
,
"--local-dns-addr"
,
"local_dns_path"
,
"--remote-dns-addr"
,
"${dns.host ?: "
0.0.0.0
"}:${if (dns.port < 0) 53 else dns.port}"
)
}
if
(
route
!=
Acl
.
ALL
)
{
if
(
route
!=
Acl
.
ALL
)
{
cmd
+=
"--acl"
cmd
+=
"--acl"
...
...
shadowsocks-rust
@
4ee01c7c
Subproject commit
ec927e6f1f01cf77211eb802d0361338906060bb
Subproject commit
4ee01c7c506a811d69b40e4dca022be42b0ad3a2
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