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
2241c5aa
Commit
2241c5aa
authored
Jan 24, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent hanging connection for retrieving remote config
parent
90b05958
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
18 additions
and
20 deletions
+18
-20
core/build.gradle
core/build.gradle
+0
-1
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+16
-14
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
+2
-1
mobile/proguard-rules.pro
mobile/proguard-rules.pro
+0
-2
tv/proguard-rules.pro
tv/proguard-rules.pro
+0
-2
No files found.
core/build.gradle
View file @
2241c5aa
...
...
@@ -67,7 +67,6 @@ dependencies {
api
'com.crashlytics.sdk.android:crashlytics:2.9.8'
api
'com.google.firebase:firebase-config:16.1.3'
api
'com.google.firebase:firebase-core:16.0.6'
api
'com.squareup.okhttp3:okhttp:3.12.1'
api
"com.takisoft.preferencex:preferencex:$preferencexVersion"
api
'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.0'
kapt
"androidx.lifecycle:lifecycle-compiler:$lifecycleVersion"
...
...
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
2241c5aa
...
...
@@ -36,11 +36,9 @@ import com.github.shadowsocks.utils.signaturesCompat
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.withContext
import
kotlinx.coroutines.withTimeout
import
okhttp3.FormBody
import
okhttp3.OkHttpClient
import
okhttp3.Request
import
java.io.File
import
java.io.IOException
import
java.net.HttpURLConnection
import
java.net.InetAddress
import
java.net.UnknownHostException
import
java.security.MessageDigest
...
...
@@ -56,19 +54,23 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
suspend
fun
init
()
{
if
(
profile
.
host
==
"198.199.101.152"
)
{
val
client
=
OkHttpClient
.
Builder
().
build
()
val
mdg
=
MessageDigest
.
getInstance
(
"SHA-1"
)
mdg
.
update
(
Core
.
packageInfo
.
signaturesCompat
.
first
().
toByteArray
())
val
requestBody
=
FormBody
.
Builder
()
.
add
(
"sig"
,
String
(
Base64
.
encode
(
mdg
.
digest
(),
0
)))
.
build
()
val
request
=
Request
.
Builder
()
.
url
(
RemoteConfig
.
proxyUrl
)
.
post
(
requestBody
)
.
build
()
val
proxies
=
withTimeout
(
30_000
)
{
withContext
(
Dispatchers
.
IO
)
{
client
.
newCall
(
request
).
execute
().
body
()
!!
.
string
()
}
val
conn
=
RemoteConfig
.
proxyUrl
.
openConnection
()
as
HttpURLConnection
conn
.
requestMethod
=
"POST"
conn
.
doOutput
=
true
val
proxies
=
try
{
withTimeout
(
30_000
)
{
withContext
(
Dispatchers
.
IO
)
{
conn
.
outputStream
.
bufferedWriter
().
use
{
it
.
write
(
"sig="
+
String
(
Base64
.
encode
(
mdg
.
digest
(),
Base64
.
DEFAULT
)))
}
conn
.
inputStream
.
bufferedReader
().
readText
()
}
}
}
finally
{
conn
.
disconnect
()
}.
split
(
'|'
).
toMutableList
()
proxies
.
shuffle
()
val
proxy
=
proxies
.
first
().
split
(
':'
)
...
...
core/src/main/java/com/github/shadowsocks/bg/RemoteConfig.kt
View file @
2241c5aa
...
...
@@ -25,11 +25,12 @@ import androidx.core.os.bundleOf
import
com.github.shadowsocks.Core
import
com.github.shadowsocks.core.R
import
com.google.firebase.remoteconfig.FirebaseRemoteConfig
import
java.net.URL
object
RemoteConfig
{
private
val
config
=
FirebaseRemoteConfig
.
getInstance
().
apply
{
setDefaults
(
R
.
xml
.
default_configs
)
}
val
proxyUrl
get
()
=
config
.
getString
(
"proxy_url"
)
val
proxyUrl
get
()
=
URL
(
config
.
getString
(
"proxy_url"
)
)
fun
fetch
()
=
config
.
fetch
().
addOnCompleteListener
{
if
(
it
.
isSuccessful
)
config
.
activateFetched
()
else
{
...
...
mobile/proguard-rules.pro
View file @
2241c5aa
...
...
@@ -22,5 +22,3 @@
#-
renamesourcefileattribute
SourceFile
-
dontwarn
com
.
google
.
android
.
gms
.
internal
.
**
-
dontwarn
okhttp3
.
**
-
dontwarn
okio
.
**
tv/proguard-rules.pro
View file @
2241c5aa
...
...
@@ -22,5 +22,3 @@
#-
renamesourcefileattribute
SourceFile
-
dontwarn
com
.
google
.
android
.
gms
.
internal
.
**
-
dontwarn
okhttp3
.
**
-
dontwarn
okio
.
**
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