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
ddef6f16
Commit
ddef6f16
authored
Jan 09, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Preliminary changes
parent
649836cf
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
43 deletions
+51
-43
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
+2
-15
core/src/main/java/com/github/shadowsocks/database/Profile.kt
.../src/main/java/com/github/shadowsocks/database/Profile.kt
+3
-6
core/src/main/java/com/github/shadowsocks/subscription/Subscription.kt
.../java/com/github/shadowsocks/subscription/Subscription.kt
+3
-20
core/src/main/java/com/github/shadowsocks/utils/Sorters.kt
core/src/main/java/com/github/shadowsocks/utils/Sorters.kt
+41
-0
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
...m/github/shadowsocks/subscription/SubscriptionFragment.kt
+2
-2
No files found.
core/src/main/java/com/github/shadowsocks/acl/Acl.kt
View file @
ddef6f16
...
...
@@ -27,6 +27,8 @@ import com.crashlytics.android.Crashlytics
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.net.Subnet
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.BaseSorter
import
com.github.shadowsocks.utils.URLSorter
import
com.github.shadowsocks.utils.asIterable
import
java.io.File
import
java.io.IOException
...
...
@@ -66,26 +68,11 @@ class Acl {
fun
save
(
id
:
String
,
acl
:
Acl
)
=
getFile
(
id
).
writeText
(
acl
.
toString
())
}
private
abstract
class
BaseSorter
<
T
>
:
SortedList
.
Callback
<
T
>()
{
override
fun
onInserted
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areContentsTheSame
(
oldItem
:
T
?,
newItem
:
T
?):
Boolean
=
oldItem
==
newItem
override
fun
onMoved
(
fromPosition
:
Int
,
toPosition
:
Int
)
{
}
override
fun
onChanged
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
onRemoved
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areItemsTheSame
(
item1
:
T
?,
item2
:
T
?):
Boolean
=
item1
==
item2
override
fun
compare
(
o1
:
T
?,
o2
:
T
?):
Int
=
if
(
o1
==
null
)
if
(
o2
==
null
)
0
else
1
else
if
(
o2
==
null
)
-
1
else
compareNonNull
(
o1
,
o2
)
abstract
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
}
private
open
class
DefaultSorter
<
T
:
Comparable
<
T
>>
:
BaseSorter
<
T
>()
{
override
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
=
o1
.
compareTo
(
o2
)
}
private
object
StringSorter
:
DefaultSorter
<
String
>()
private
object
SubnetSorter
:
DefaultSorter
<
Subnet
>()
private
object
URLSorter
:
BaseSorter
<
URL
>()
{
private
val
ordering
=
compareBy
<
URL
>({
it
.
host
},
{
it
.
port
},
{
it
.
file
},
{
it
.
protocol
})
override
fun
compareNonNull
(
o1
:
URL
,
o2
:
URL
):
Int
=
ordering
.
compare
(
o1
,
o2
)
}
val
bypassHostnames
=
SortedList
(
String
::
class
.
java
,
StringSorter
)
val
proxyHostnames
=
SortedList
(
String
::
class
.
java
,
StringSorter
)
...
...
core/src/main/java/com/github/shadowsocks/database/Profile.kt
View file @
ddef6f16
...
...
@@ -82,8 +82,7 @@ data class Profile(
private
val
userInfoPattern
=
"^(.+?):(.*)$"
.
toRegex
()
private
val
legacyPattern
=
"^(.+?):(.*)@(.+?):(\\d+?)$"
.
toRegex
()
fun
findAllUrls
(
data
:
CharSequence
?,
feature
:
Profile
?
=
null
)
=
pattern
.
findAll
(
data
?:
""
).
map
{
fun
findAllUrls
(
data
:
CharSequence
?,
feature
:
Profile
?
=
null
)
=
pattern
.
findAll
(
data
?:
""
).
map
{
val
uri
=
it
.
value
.
toUri
()
try
{
if
(
uri
.
userInfo
==
null
)
{
...
...
@@ -179,10 +178,8 @@ data class Profile(
(
json
[
"proxy_apps"
]
as
?
JsonObject
)
?.
also
{
proxyApps
=
it
[
"enabled"
].
optBoolean
?:
proxyApps
bypass
=
it
[
"bypass"
].
optBoolean
?:
bypass
individual
=
(
it
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
joinToString
(
"\n"
)
?:
individual
// JSONArray will return strings with "", which should be removed
individual
=
individual
.
replace
(
"\""
,
""
)
individual
=
(
it
[
"android_list"
]
as
?
JsonArray
)
?.
asIterable
()
?.
mapNotNull
{
it
.
optString
}
?.
joinToString
(
"\n"
)
?:
individual
}
udpdns
=
json
[
"udpdns"
].
optBoolean
?:
udpdns
(
json
[
"udp_fallback"
]
as
?
JsonObject
)
?.
let
{
tryParse
(
it
,
true
)
}
?.
also
{
fallbackMap
[
this
]
=
it
}
...
...
core/src/main/java/com/github/shadowsocks/subscription/Subscription.kt
View file @
ddef6f16
/*******************************************************************************
* *
* Copyright (C) 20
17
by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 20
17
by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* Copyright (C) 20
20
by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 20
20
by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
...
...
@@ -22,6 +22,7 @@ package com.github.shadowsocks.subscription
import
androidx.recyclerview.widget.SortedList
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.URLSorter
import
com.github.shadowsocks.utils.asIterable
import
java.io.Reader
import
java.net.URL
...
...
@@ -40,24 +41,6 @@ class Subscription {
set
(
value
)
=
DataStore
.
publicStore
.
putString
(
SUBSCRIPTION
,
value
.
toString
())
}
private
abstract
class
BaseSorter
<
T
>
:
SortedList
.
Callback
<
T
>()
{
override
fun
onInserted
(
position
:
Int
,
count
:
Int
)
{}
override
fun
areContentsTheSame
(
oldItem
:
T
?,
newItem
:
T
?):
Boolean
=
oldItem
==
newItem
override
fun
onMoved
(
fromPosition
:
Int
,
toPosition
:
Int
)
{}
override
fun
onChanged
(
position
:
Int
,
count
:
Int
)
{}
override
fun
onRemoved
(
position
:
Int
,
count
:
Int
)
{}
override
fun
areItemsTheSame
(
item1
:
T
?,
item2
:
T
?):
Boolean
=
item1
==
item2
override
fun
compare
(
o1
:
T
?,
o2
:
T
?):
Int
=
if
(
o1
==
null
)
if
(
o2
==
null
)
0
else
1
else
if
(
o2
==
null
)
-
1
else
compareNonNull
(
o1
,
o2
)
abstract
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
}
private
object
URLSorter
:
BaseSorter
<
URL
>()
{
private
val
ordering
=
compareBy
<
URL
>({
it
.
host
},
{
it
.
port
},
{
it
.
file
},
{
it
.
protocol
})
override
fun
compareNonNull
(
o1
:
URL
,
o2
:
URL
):
Int
=
ordering
.
compare
(
o1
,
o2
)
}
val
urls
=
SortedList
(
URL
::
class
.
java
,
URLSorter
)
fun
fromReader
(
reader
:
Reader
):
Subscription
{
...
...
core/src/main/java/com/github/shadowsocks/utils/Sorters.kt
0 → 100644
View file @
ddef6f16
/*******************************************************************************
* *
* Copyright (C) 2020 by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 2020 by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
* *
*******************************************************************************/
package
com.github.shadowsocks.utils
import
androidx.recyclerview.widget.SortedList
import
java.net.URL
abstract
class
BaseSorter
<
T
>
:
SortedList
.
Callback
<
T
>()
{
override
fun
onInserted
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areContentsTheSame
(
oldItem
:
T
?,
newItem
:
T
?):
Boolean
=
oldItem
==
newItem
override
fun
onMoved
(
fromPosition
:
Int
,
toPosition
:
Int
)
{
}
override
fun
onChanged
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
onRemoved
(
position
:
Int
,
count
:
Int
)
{
}
override
fun
areItemsTheSame
(
item1
:
T
?,
item2
:
T
?):
Boolean
=
item1
==
item2
override
fun
compare
(
o1
:
T
?,
o2
:
T
?):
Int
=
if
(
o1
==
null
)
if
(
o2
==
null
)
0
else
1
else
if
(
o2
==
null
)
-
1
else
compareNonNull
(
o1
,
o2
)
abstract
fun
compareNonNull
(
o1
:
T
,
o2
:
T
):
Int
}
object
URLSorter
:
BaseSorter
<
URL
>()
{
private
val
ordering
=
compareBy
<
URL
>({
it
.
host
},
{
it
.
port
},
{
it
.
file
},
{
it
.
protocol
})
override
fun
compareNonNull
(
o1
:
URL
,
o2
:
URL
):
Int
=
ordering
.
compare
(
o1
,
o2
)
}
mobile/src/main/java/com/github/shadowsocks/subscription/SubscriptionFragment.kt
View file @
ddef6f16
/*******************************************************************************
* *
* Copyright (C) 20
17
by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 20
17
by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* Copyright (C) 20
20
by Max Lv <max.c.lv@gmail.com> *
* Copyright (C) 20
20
by Mygod Studio <contact-shadowsocks-android@mygod.be> *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
...
...
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