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
b161ab81
Commit
b161ab81
authored
Feb 23, 2022
by
chenhuaqing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed bug
parent
5b98f8d8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
26 deletions
+19
-26
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
+17
-24
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
+1
-1
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+1
-1
No files found.
core/src/main/java/com/github/shadowsocks/bg/AuthManager.kt
View file @
b161ab81
...
@@ -2,19 +2,16 @@ package com.github.shadowsocks.bg
...
@@ -2,19 +2,16 @@ package com.github.shadowsocks.bg
import
android.os.Build
import
android.os.Build
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.acl.Acl
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.database.ProfileManager
import
com.github.shadowsocks.http.FreshToken
import
com.github.shadowsocks.http.FreshToken
import
com.github.shadowsocks.http.HttpConfig
import
com.github.shadowsocks.http.LineConfig
import
com.github.shadowsocks.http.LineConfig
import
com.google.gson.Gson
import
com.google.gson.Gson
import
com.google.gson.JsonStreamParser
import
com.google.gson.JsonStreamParser
import
com.google.gson.reflect.TypeToken
import
com.google.gson.reflect.TypeToken
import
com.tencent.mmkv.MMKV
import
com.tencent.mmkv.MMKV
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withContext
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.MediaType.Companion.toMediaTypeOrNull
import
okhttp3.OkHttpClient
import
okhttp3.OkHttpClient
...
@@ -80,18 +77,16 @@ object AuthManager {
...
@@ -80,18 +77,16 @@ object AuthManager {
MMKV
.
defaultMMKV
().
putLong
(
"ACC_TIME"
,
acc_time
)
MMKV
.
defaultMMKV
().
putLong
(
"ACC_TIME"
,
acc_time
)
}
}
suspend
fun
initAuthProfile
()
{
suspend
fun
initAuthProfile
(
profile
:
Profile
)
{
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
getLineConfig
()
?.
let
{
getLineConfig
()
?.
let
{
if
(
it
.
code
!=
200
)
{
if
(
it
.
code
!=
200
)
{
return
@withContext
return
@withContext
}
}
val
profileId
=
1L
val
profile
=
ProfileManager
.
getProfile
(
profileId
)
?:
Profile
()
profile
.
host
=
it
.
data
.
host
profile
.
host
=
it
.
data
.
host
profile
.
token
=
it
.
data
.
token
profile
.
token
=
it
.
data
.
token
profile
.
remotePort
=
it
.
data
.
port
profile
.
remotePort
=
it
.
data
.
port
Timber
.
d
(
"start vpn with games: ${profile.individual}"
)
Timber
.
d
(
"start vpn with games: ${profile.individual}
, profileId: ${profile.id}, route: ${profile.route}
"
)
ProfileManager
.
updateProfile
(
profile
)
ProfileManager
.
updateProfile
(
profile
)
}
}
}
}
...
@@ -101,7 +96,7 @@ object AuthManager {
...
@@ -101,7 +96,7 @@ object AuthManager {
if
(
data
.
state
!=
BaseService
.
State
.
Connected
)
{
if
(
data
.
state
!=
BaseService
.
State
.
Connected
)
{
return
return
}
}
scheduleAtFixedRate
?.
cancel
(
false
)
scheduleAtFixedRate
=
executor
.
scheduleAtFixedRate
({
scheduleAtFixedRate
=
executor
.
scheduleAtFixedRate
({
val
context
=
val
context
=
if
(
Build
.
VERSION
.
SDK_INT
<
24
||
Core
.
user
.
isUserUnlocked
)
Core
.
app
else
Core
.
deviceStorage
if
(
Build
.
VERSION
.
SDK_INT
<
24
||
Core
.
user
.
isUserUnlocked
)
Core
.
app
else
Core
.
deviceStorage
...
@@ -110,9 +105,10 @@ object AuthManager {
...
@@ -110,9 +105,10 @@ object AuthManager {
.
single
().
asJsonObject
.
single
().
asJsonObject
if
(
data
.
state
==
BaseService
.
State
.
Connected
)
{
if
(
data
.
state
==
BaseService
.
State
.
Connected
)
{
data
.
proxy
?.
let
{
proxyInstance
->
getToken
(
)
?.
let
{
getToken
(
proxyInstance
.
profile
.
token
?:
""
)
?.
let
{
if
(
it
.
code
==
200
)
{
if
(
it
.
code
==
200
)
{
proxyInstance
.
profile
.
token
=
it
.
data
.
token
configJson
.
addProperty
(
"token"
,
it
.
data
.
token
)
configJson
.
addProperty
(
"token"
,
it
.
data
.
token
)
configFile
.
writeText
(
configJson
.
toString
())
configFile
.
writeText
(
configJson
.
toString
())
}
else
{
}
else
{
...
@@ -120,23 +116,20 @@ object AuthManager {
...
@@ -120,23 +116,20 @@ object AuthManager {
}
}
}
}
}
}
}
},
1
,
1
,
TimeUnit
.
MINUTES
)
},
1
,
1
,
TimeUnit
.
MINUTES
)
}
}
fun
getToken
():
FreshToken
?
{
fun
getToken
(
token
:
String
):
FreshToken
?
{
ProfileManager
.
getProfile
(
1L
)
?.
let
{
val
map
=
mapOf
(
Pair
(
"token"
,
token
))
val
map
=
mutableMapOf
<
String
,
String
>()
it
.
token
?.
let
{
it1
->
map
.
put
(
"token"
,
it1
)
}
return
postSync
<
FreshToken
>(
"/api/acc/line/refresh"
,
map
)
return
postSync
<
FreshToken
>(
"/api/acc/line/refresh"
,
map
)
}
}
return
null
}
val
jsonType
get
()
=
"application/json; charset=utf-8"
.
toMediaTypeOrNull
()
val
jsonType
get
()
=
"application/json; charset=utf-8"
.
toMediaTypeOrNull
()
fun
getLineConfig
(
private
fun
getLineConfig
(
):
LineConfig
?
{
):
LineConfig
?
{
val
map
=
mutableMapOf
<
String
,
String
>()
val
map
=
mutableMapOf
<
String
,
String
>()
area
?.
let
{
map
.
put
(
"area"
,
it
)
}
area
?.
let
{
map
.
put
(
"area"
,
it
)
}
...
...
core/src/main/java/com/github/shadowsocks/bg/BaseService.kt
View file @
b161ab81
...
@@ -348,7 +348,7 @@ object BaseService {
...
@@ -348,7 +348,7 @@ object BaseService {
try
{
try
{
Executable
.
killAll
()
// clean up old processes
Executable
.
killAll
()
// clean up old processes
preInit
()
preInit
()
AuthManager
.
initAuthProfile
()
AuthManager
.
initAuthProfile
(
profile
)
if
(
profile
.
route
==
Acl
.
CUSTOM_RULES
)
try
{
if
(
profile
.
route
==
Acl
.
CUSTOM_RULES
)
try
{
withContext
(
Dispatchers
.
IO
)
{
withContext
(
Dispatchers
.
IO
)
{
Acl
.
customRules
.
flatten
(
10
,
this
@Interface
::
openConnection
).
also
{
Acl
.
customRules
.
flatten
(
10
,
this
@Interface
::
openConnection
).
also
{
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
b161ab81
...
@@ -129,7 +129,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -129,7 +129,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
}
}
fun
scheduleUpdate
()
{
fun
scheduleUpdate
()
{
if
(
route
!
in
arrayOf
(
Acl
.
ALL
,
Acl
.
CUSTOM_RULES
))
AclSyncer
.
schedule
(
route
)
if
(
route
!
in
arrayOf
(
Acl
.
ALL
,
Acl
.
CUSTOM_RULES
,
Acl
.
BYPASS_LAN
))
AclSyncer
.
schedule
(
route
)
}
}
fun
shutdown
(
scope
:
CoroutineScope
)
{
fun
shutdown
(
scope
:
CoroutineScope
)
{
...
...
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