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
36bf02de
Commit
36bf02de
authored
Jan 11, 2020
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Regard udpFallback as server settings
parent
08b2b87c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
16 deletions
+23
-16
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
...in/java/com/github/shadowsocks/database/ProfileManager.kt
+14
-13
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
+6
-0
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
...main/java/com/github/shadowsocks/ProfileConfigFragment.kt
+3
-3
No files found.
core/src/main/java/com/github/shadowsocks/database/ProfileManager.kt
View file @
36bf02de
...
@@ -55,13 +55,13 @@ object ProfileManager {
...
@@ -55,13 +55,13 @@ object ProfileManager {
fun
createProfilesFromSubscription
(
jsons
:
Sequence
<
InputStream
>)
{
fun
createProfilesFromSubscription
(
jsons
:
Sequence
<
InputStream
>)
{
val
currentId
=
DataStore
.
profileId
val
currentId
=
DataStore
.
profileId
val
profiles
=
getAllProfiles
()
val
profiles
=
getAllProfiles
()
val
subscriptions
=
mutableMapOf
<
String
,
Profile
>()
val
subscriptions
=
mutableMapOf
<
Pair
<
String
?
,
String
>
,
Profile
>()
val
toUpdate
=
mutableSetOf
<
Long
>()
val
toUpdate
=
mutableSetOf
<
Long
>()
var
feature
:
Profile
?
=
null
var
feature
:
Profile
?
=
null
profiles
?.
forEach
{
profile
->
// preprocessing phase
profiles
?.
forEach
{
profile
->
// preprocessing phase
if
(
currentId
==
profile
.
id
)
feature
=
profile
if
(
currentId
==
profile
.
id
)
feature
=
profile
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
UserConfigured
)
return
@forEach
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
UserConfigured
)
return
@forEach
if
(
subscriptions
.
putIfAbsentCompat
(
profile
.
formattedAddress
,
profile
)
!=
null
)
{
if
(
subscriptions
.
putIfAbsentCompat
(
profile
.
name
to
profile
.
formattedAddress
,
profile
)
!=
null
)
{
delProfile
(
profile
.
id
)
delProfile
(
profile
.
id
)
if
(
currentId
==
profile
.
id
)
DataStore
.
profileId
=
0
if
(
currentId
==
profile
.
id
)
DataStore
.
profileId
=
0
}
else
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
Active
)
{
}
else
if
(
profile
.
subscription
==
Profile
.
SubscriptionStatus
.
Active
)
{
...
@@ -72,18 +72,19 @@ object ProfileManager {
...
@@ -72,18 +72,19 @@ object ProfileManager {
jsons
.
asIterable
().
forEachTry
{
json
->
jsons
.
asIterable
().
forEachTry
{
json
->
Profile
.
parseJson
(
JsonStreamParser
(
json
.
bufferedReader
()).
asSequence
().
single
(),
feature
)
{
Profile
.
parseJson
(
JsonStreamParser
(
json
.
bufferedReader
()).
asSequence
().
single
(),
feature
)
{
val
oldProfile
=
subscriptions
[
it
.
formattedAddress
]
subscriptions
.
computeCompat
(
it
.
name
to
it
.
formattedAddress
)
{
_
,
oldProfile
->
when
(
oldProfile
?.
subscription
)
{
when
(
oldProfile
?.
subscription
)
{
Profile
.
SubscriptionStatus
.
Active
->
{
}
// skip dup subscription
Profile
.
SubscriptionStatus
.
Active
->
oldProfile
// skip dup subscription
Profile
.
SubscriptionStatus
.
Obsolete
->
{
Profile
.
SubscriptionStatus
.
Obsolete
->
{
oldProfile
.
password
=
it
.
password
oldProfile
.
password
=
it
.
password
oldProfile
.
method
=
it
.
method
oldProfile
.
method
=
it
.
method
oldProfile
.
plugin
=
it
.
plugin
oldProfile
.
udpFallback
=
it
.
udpFallback
oldProfile
.
subscription
=
Profile
.
SubscriptionStatus
.
Active
oldProfile
.
subscription
=
Profile
.
SubscriptionStatus
.
Active
oldProfile
}
else
->
createProfile
(
it
.
apply
{
subscription
=
Profile
.
SubscriptionStatus
.
Active
})
}
}
else
->
createProfile
(
it
.
apply
{
subscription
=
Profile
.
SubscriptionStatus
.
Active
subscriptions
[
it
.
formattedAddress
]
=
it
})
}
}
}
}
}
}
...
...
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
36bf02de
...
@@ -89,6 +89,12 @@ fun String?.parseNumericAddress(): InetAddress? = Os.inet_pton(OsConstants.AF_IN
...
@@ -89,6 +89,12 @@ fun String?.parseNumericAddress(): InetAddress? = Os.inet_pton(OsConstants.AF_IN
if
(
Build
.
VERSION
.
SDK_INT
>=
29
)
it
else
parseNumericAddress
.
invoke
(
null
,
this
)
as
InetAddress
if
(
Build
.
VERSION
.
SDK_INT
>=
29
)
it
else
parseNumericAddress
.
invoke
(
null
,
this
)
as
InetAddress
}
}
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
computeCompat
(
key
:
K
,
remappingFunction
:
(
K
,
V
?)
->
V
?)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
val
oldValue
=
get
(
key
)
remappingFunction
(
key
,
oldValue
).
also
{
newValue
->
if
(
newValue
!=
null
)
put
(
key
,
newValue
)
else
if
(
oldValue
!=
null
||
containsKey
(
key
))
remove
(
key
)
}
}
else
compute
(
key
)
{
k
,
oldValue
->
remappingFunction
(
k
,
oldValue
)
}
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
computeIfAbsentCompat
(
key
:
K
,
value
:
()
->
V
)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
fun
<
K
,
V
>
MutableMap
<
K
,
V
>.
computeIfAbsentCompat
(
key
:
K
,
value
:
()
->
V
)
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
)
{
this
[
key
]
?:
value
().
also
{
put
(
key
,
it
)
}
this
[
key
]
?:
value
().
also
{
put
(
key
,
it
)
}
}
else
computeIfAbsent
(
key
)
{
value
()
}
}
else
computeIfAbsent
(
key
)
{
value
()
}
...
...
mobile/src/main/java/com/github/shadowsocks/ProfileConfigFragment.kt
View file @
36bf02de
...
@@ -126,9 +126,9 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
...
@@ -126,9 +126,9 @@ class ProfileConfigFragment : PreferenceFragmentCompat(),
findPreference
<
Preference
>(
Key
.
password
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
password
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
method
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
method
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
remotePort
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
remotePort
)
!!
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
plugin
)
!!
.
isEnabled
=
false
plugin
.
isEnabled
=
false
findPreference
<
Preference
>(
Key
.
pluginConfigure
)
!!
.
isEnabled
=
false
pluginConfigure
.
isEnabled
=
false
udpFallback
.
isEnabled
=
false
}
}
}
}
...
...
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