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
9f122193
Commit
9f122193
authored
Apr 23, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use file to persist custom rules to avoid 1MB limit
parent
f3b2920d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
core/src/main/java/com/github/shadowsocks/Core.kt
core/src/main/java/com/github/shadowsocks/Core.kt
+2
-2
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
+4
-6
No files found.
core/src/main/java/com/github/shadowsocks/Core.kt
View file @
9f122193
...
@@ -97,9 +97,9 @@ object Core {
...
@@ -97,9 +97,9 @@ object Core {
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
// migrate old files
if
(
Build
.
VERSION
.
SDK_INT
>=
24
)
{
// migrate old files
deviceStorage
.
moveDatabaseFrom
(
app
,
Key
.
DB_PUBLIC
)
deviceStorage
.
moveDatabaseFrom
(
app
,
Key
.
DB_PUBLIC
)
val
old
=
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
,
app
)
val
old
=
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
_USER
,
app
)
if
(
old
.
canRead
())
{
if
(
old
.
canRead
())
{
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
).
writeText
(
old
.
readText
())
Acl
.
getFile
(
Acl
.
CUSTOM_RULES
_USER
).
writeText
(
old
.
readText
())
old
.
delete
()
old
.
delete
()
}
}
}
}
...
...
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
View file @
9f122193
...
@@ -24,7 +24,6 @@ import android.content.Context
...
@@ -24,7 +24,6 @@ import android.content.Context
import
androidx.recyclerview.widget.SortedList
import
androidx.recyclerview.widget.SortedList
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.BaseSorter
import
com.github.shadowsocks.utils.BaseSorter
import
com.github.shadowsocks.utils.URLSorter
import
com.github.shadowsocks.utils.URLSorter
import
com.github.shadowsocks.utils.asIterable
import
com.github.shadowsocks.utils.asIterable
...
@@ -48,6 +47,7 @@ class Acl {
...
@@ -48,6 +47,7 @@ class Acl {
const
val
GFWLIST
=
"gfwlist"
const
val
GFWLIST
=
"gfwlist"
const
val
CHINALIST
=
"china-list"
const
val
CHINALIST
=
"china-list"
const
val
CUSTOM_RULES
=
"custom-rules"
const
val
CUSTOM_RULES
=
"custom-rules"
const
val
CUSTOM_RULES_USER
=
"custom-rules-user"
private
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
private
val
networkAclParser
=
"^IMPORT_URL\\s*<(.+)>\\s*$"
.
toRegex
()
...
@@ -56,17 +56,15 @@ class Acl {
...
@@ -56,17 +56,15 @@ class Acl {
var
customRules
:
Acl
var
customRules
:
Acl
get
()
{
get
()
{
val
acl
=
Acl
()
val
acl
=
Acl
()
val
str
=
DataStore
.
publicStore
.
getString
(
CUSTOM_RULES
)
val
file
=
getFile
(
CUSTOM_RULES_USER
)
if
(
str
!=
null
)
acl
.
fromReader
(
str
.
reader
(),
true
)
if
(
file
.
canRead
())
acl
.
fromReader
(
file
.
reader
(),
true
)
if
(!
acl
.
bypass
)
{
if
(!
acl
.
bypass
)
{
acl
.
bypass
=
true
acl
.
bypass
=
true
acl
.
subnets
.
clear
()
acl
.
subnets
.
clear
()
}
}
return
acl
return
acl
}
}
set
(
value
)
=
DataStore
.
publicStore
.
putString
(
CUSTOM_RULES
,
set
(
value
)
=
getFile
(
CUSTOM_RULES_USER
).
writeText
(
value
.
toString
())
if
((!
value
.
bypass
||
value
.
subnets
.
size
()
==
0
)
&&
value
.
bypassHostnames
.
size
()
==
0
&&
value
.
proxyHostnames
.
size
()
==
0
&&
value
.
urls
.
size
()
==
0
)
null
else
value
.
toString
())
fun
save
(
id
:
String
,
acl
:
Acl
)
=
getFile
(
id
).
writeText
(
acl
.
toString
())
fun
save
(
id
:
String
,
acl
:
Acl
)
=
getFile
(
id
).
writeText
(
acl
.
toString
())
suspend
fun
<
T
>
parse
(
reader
:
Reader
,
bypassHostnames
:
(
String
)
->
T
,
proxyHostnames
:
(
String
)
->
T
,
suspend
fun
<
T
>
parse
(
reader
:
Reader
,
bypassHostnames
:
(
String
)
->
T
,
proxyHostnames
:
(
String
)
->
T
,
...
...
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