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
7f4624f3
Commit
7f4624f3
authored
Nov 09, 2018
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prefer noBackupFilesDir
parent
e02f9690
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
13 additions
and
18 deletions
+13
-18
core/src/main/java/com/github/shadowsocks/Core.kt
core/src/main/java/com/github/shadowsocks/Core.kt
+1
-1
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+4
-9
core/src/main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
...main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
...rc/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
...in/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
.../main/java/com/github/shadowsocks/bg/TransproxyService.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
+2
-2
core/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
.../main/java/com/github/shadowsocks/plugin/PluginManager.kt
+1
-1
No files found.
core/src/main/java/com/github/shadowsocks/Core.kt
View file @
7f4624f3
...
@@ -116,7 +116,7 @@ object Core {
...
@@ -116,7 +116,7 @@ object Core {
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
for
(
dir
in
arrayOf
(
"acl"
,
"overture"
))
try
{
try
{
for
(
file
in
assetManager
.
list
(
dir
)
!!
)
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
for
(
file
in
assetManager
.
list
(
dir
)
!!
)
assetManager
.
open
(
"$dir/$file"
).
use
{
input
->
File
(
deviceStorage
.
f
ilesDir
,
file
).
outputStream
().
use
{
output
->
input
.
copyTo
(
output
)
}
File
(
deviceStorage
.
noBackupF
ilesDir
,
file
).
outputStream
().
use
{
output
->
input
.
copyTo
(
output
)
}
}
}
}
catch
(
e
:
IOException
)
{
}
catch
(
e
:
IOException
)
{
printLog
(
e
)
printLog
(
e
)
...
...
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
View file @
7f4624f3
...
@@ -46,7 +46,7 @@ class Acl {
...
@@ -46,7 +46,7 @@ class Acl {
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
fun
getFile
(
id
:
String
,
context
:
Context
=
Core
.
deviceStorage
)
=
File
(
context
.
f
ilesDir
,
"$id.acl"
)
fun
getFile
(
id
:
String
,
context
:
Context
=
Core
.
deviceStorage
)
=
File
(
context
.
noBackupF
ilesDir
,
"$id.acl"
)
var
customRules
:
Acl
var
customRules
:
Acl
get
()
{
get
()
{
...
...
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
7f4624f3
...
@@ -20,18 +20,14 @@
...
@@ -20,18 +20,14 @@
package
com.github.shadowsocks.bg
package
com.github.shadowsocks.bg
import
android.annotation.TargetApi
import
android.app.Service
import
android.app.Service
import
android.content.Context
import
android.content.Context
import
android.content.Intent
import
android.content.Intent
import
android.content.IntentFilter
import
android.content.IntentFilter
import
android.os.Build
import
android.os.*
import
android.os.IBinder
import
android.os.RemoteCallbackList
import
android.os.SystemClock
import
android.util.Base64
import
android.util.Base64
import
android.util.Log
import
android.util.Log
import
androidx.core.
os.UserManagerCompat
import
androidx.core.
content.getSystemService
import
androidx.core.os.bundleOf
import
androidx.core.os.bundleOf
import
com.crashlytics.android.Crashlytics
import
com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
...
@@ -195,9 +191,8 @@ object BaseService {
...
@@ -195,9 +191,8 @@ object BaseService {
.
put
(
"plugin_opts"
,
plugin
.
toString
())
.
put
(
"plugin_opts"
,
plugin
.
toString
())
}
}
// sensitive Shadowsocks config is stored in
// sensitive Shadowsocks config is stored in
return
File
(
if
(
UserManagerCompat
.
isUserUnlocked
(
app
))
app
.
filesDir
else
@TargetApi
(
24
)
{
return
File
((
if
(
Build
.
VERSION
.
SDK_INT
<
24
||
app
.
getSystemService
<
UserManager
>()
?.
isUserUnlocked
!=
true
)
Core
.
deviceStorage
.
noBackupFilesDir
// only API 24+ will be in locked state
app
else
Core
.
deviceStorage
).
noBackupFilesDir
,
CONFIG_FILE
).
apply
{
},
CONFIG_FILE
).
apply
{
shadowsocksConfigFile
=
this
shadowsocksConfigFile
=
this
writeText
(
config
.
toString
())
writeText
(
config
.
toString
())
}
}
...
...
core/src/main/java/com/github/shadowsocks/bg/GuardedProcessPool.kt
View file @
7f4624f3
...
@@ -70,7 +70,7 @@ class GuardedProcessPool {
...
@@ -70,7 +70,7 @@ class GuardedProcessPool {
process
=
ProcessBuilder
(
cmd
)
process
=
ProcessBuilder
(
cmd
)
.
redirectErrorStream
(
true
)
.
redirectErrorStream
(
true
)
.
directory
(
Core
.
deviceStorage
.
f
ilesDir
)
.
directory
(
Core
.
deviceStorage
.
noBackupF
ilesDir
)
.
start
()
.
start
()
streamLogger
(
process
.
inputStream
,
Log
::
i
)
streamLogger
(
process
.
inputStream
,
Log
::
i
)
...
...
core/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt
View file @
7f4624f3
...
@@ -52,7 +52,7 @@ object LocalDnsService {
...
@@ -52,7 +52,7 @@ object LocalDnsService {
}
}
fun
buildOvertureConfig
(
file
:
String
)
=
file
.
also
{
fun
buildOvertureConfig
(
file
:
String
)
=
file
.
also
{
File
(
Core
.
deviceStorage
.
f
ilesDir
,
it
).
writeText
(
JSONObject
().
run
{
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
it
).
writeText
(
JSONObject
().
run
{
put
(
"BindAddress"
,
"${DataStore.listenAddress}:${DataStore.portLocalDns}"
)
put
(
"BindAddress"
,
"${DataStore.listenAddress}:${DataStore.portLocalDns}"
)
put
(
"RedirectIPv6Record"
,
true
)
put
(
"RedirectIPv6Record"
,
true
)
put
(
"DomainBase64Decode"
,
false
)
put
(
"DomainBase64Decode"
,
false
)
...
...
core/src/main/java/com/github/shadowsocks/bg/TrafficMonitorThread.kt
View file @
7f4624f3
...
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer
...
@@ -29,7 +29,7 @@ import java.nio.ByteBuffer
import
java.nio.ByteOrder
import
java.nio.ByteOrder
class
TrafficMonitorThread
:
LocalSocketListener
(
"TrafficMonitorThread"
)
{
class
TrafficMonitorThread
:
LocalSocketListener
(
"TrafficMonitorThread"
)
{
override
val
socketFile
=
File
(
Core
.
deviceStorage
.
f
ilesDir
,
"stat_path"
)
override
val
socketFile
=
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
"stat_path"
)
override
fun
accept
(
socket
:
LocalSocket
)
{
override
fun
accept
(
socket
:
LocalSocket
)
{
try
{
try
{
...
...
core/src/main/java/com/github/shadowsocks/bg/TransproxyService.kt
View file @
7f4624f3
...
@@ -52,7 +52,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
...
@@ -52,7 +52,7 @@ class TransproxyService : Service(), LocalDnsService.Interface {
}
}
private
fun
startRedsocksDaemon
()
{
private
fun
startRedsocksDaemon
()
{
File
(
Core
.
deviceStorage
.
f
ilesDir
,
"redsocks.conf"
).
writeText
(
"""base {
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
"redsocks.conf"
).
writeText
(
"""base {
log_debug = off;
log_debug = off;
log_info = off;
log_info = off;
log = stderr;
log = stderr;
...
...
core/src/main/java/com/github/shadowsocks/bg/VpnService.kt
View file @
7f4624f3
...
@@ -74,7 +74,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -74,7 +74,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
}
}
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
private
inner
class
ProtectWorker
:
LocalSocketListener
(
"ShadowsocksVpnThread"
)
{
override
val
socketFile
:
File
=
File
(
Core
.
deviceStorage
.
f
ilesDir
,
"protect_path"
)
override
val
socketFile
:
File
=
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
"protect_path"
)
override
fun
accept
(
socket
:
LocalSocket
)
{
override
fun
accept
(
socket
:
LocalSocket
)
{
try
{
try
{
...
@@ -259,7 +259,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
...
@@ -259,7 +259,7 @@ class VpnService : BaseVpnService(), LocalDnsService.Interface {
private
fun
sendFd
(
fd
:
Int
)
{
private
fun
sendFd
(
fd
:
Int
)
{
if
(
fd
==
-
1
)
throw
IOException
(
"Invalid fd (-1)"
)
if
(
fd
==
-
1
)
throw
IOException
(
"Invalid fd (-1)"
)
var
tries
=
0
var
tries
=
0
val
path
=
File
(
Core
.
deviceStorage
.
f
ilesDir
,
"sock_path"
).
absolutePath
val
path
=
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
"sock_path"
).
absolutePath
while
(
true
)
try
{
while
(
true
)
try
{
Thread
.
sleep
(
30L
shl
tries
)
Thread
.
sleep
(
30L
shl
tries
)
JniHelper
.
sendFd
(
fd
,
path
)
JniHelper
.
sendFd
(
fd
,
path
)
...
...
core/src/main/java/com/github/shadowsocks/plugin/PluginManager.kt
View file @
7f4624f3
...
@@ -163,7 +163,7 @@ object PluginManager {
...
@@ -163,7 +163,7 @@ object PluginManager {
var
initialized
=
false
var
initialized
=
false
fun
entryNotFound
():
Nothing
=
throw
IndexOutOfBoundsException
(
"Plugin entry binary not found"
)
fun
entryNotFound
():
Nothing
=
throw
IndexOutOfBoundsException
(
"Plugin entry binary not found"
)
val
list
=
ArrayList
<
String
>()
val
list
=
ArrayList
<
String
>()
val
pluginDir
=
File
(
Core
.
deviceStorage
.
f
ilesDir
,
"plugin"
)
val
pluginDir
=
File
(
Core
.
deviceStorage
.
noBackupF
ilesDir
,
"plugin"
)
(
cr
.
query
(
uri
,
arrayOf
(
PluginContract
.
COLUMN_PATH
,
PluginContract
.
COLUMN_MODE
),
null
,
null
,
null
)
(
cr
.
query
(
uri
,
arrayOf
(
PluginContract
.
COLUMN_PATH
,
PluginContract
.
COLUMN_MODE
),
null
,
null
,
null
)
?:
return
null
).
use
{
cursor
->
?:
return
null
).
use
{
cursor
->
if
(!
cursor
.
moveToFirst
())
entryNotFound
()
if
(!
cursor
.
moveToFirst
())
entryNotFound
()
...
...
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