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
e8127920
Commit
e8127920
authored
Feb 03, 2019
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disconnect from main thread properly
parent
7ef7644e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
2 deletions
+12
-2
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
.../src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
+2
-1
core/src/main/java/com/github/shadowsocks/net/HttpsTest.kt
core/src/main/java/com/github/shadowsocks/net/HttpsTest.kt
+2
-1
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
+8
-0
No files found.
core/src/main/java/com/github/shadowsocks/bg/ProxyInstance.kt
View file @
e8127920
...
@@ -31,6 +31,7 @@ import com.github.shadowsocks.plugin.PluginConfiguration
...
@@ -31,6 +31,7 @@ import com.github.shadowsocks.plugin.PluginConfiguration
import
com.github.shadowsocks.plugin.PluginManager
import
com.github.shadowsocks.plugin.PluginManager
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.DirectBoot
import
com.github.shadowsocks.utils.disconnectFromMain
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.parseNumericAddress
import
com.github.shadowsocks.utils.signaturesCompat
import
com.github.shadowsocks.utils.signaturesCompat
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.Dispatchers
...
@@ -70,7 +71,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
...
@@ -70,7 +71,7 @@ class ProxyInstance(val profile: Profile, private val route: String = profile.ro
}
}
}
}
}
finally
{
}
finally
{
conn
.
disconnect
()
conn
.
disconnect
FromMain
()
}.
split
(
'|'
).
toMutableList
()
}.
split
(
'|'
).
toMutableList
()
proxies
.
shuffle
()
proxies
.
shuffle
()
val
proxy
=
proxies
.
first
().
split
(
':'
)
val
proxy
=
proxies
.
first
().
split
(
':'
)
...
...
core/src/main/java/com/github/shadowsocks/net/HttpsTest.kt
View file @
e8127920
...
@@ -30,6 +30,7 @@ import com.github.shadowsocks.acl.Acl
...
@@ -30,6 +30,7 @@ import com.github.shadowsocks.acl.Acl
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.core.R
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.preference.DataStore
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.Key
import
com.github.shadowsocks.utils.disconnectFromMain
import
kotlinx.coroutines.*
import
kotlinx.coroutines.*
import
java.io.IOException
import
java.io.IOException
import
java.net.HttpURLConnection
import
java.net.HttpURLConnection
...
@@ -109,7 +110,7 @@ class HttpsTest : ViewModel() {
...
@@ -109,7 +110,7 @@ class HttpsTest : ViewModel() {
private
fun
cancelTest
()
=
running
?.
let
{
(
conn
,
job
)
->
private
fun
cancelTest
()
=
running
?.
let
{
(
conn
,
job
)
->
job
.
cancel
()
// ensure job is cancelled before interrupting
job
.
cancel
()
// ensure job is cancelled before interrupting
conn
.
disconnect
()
conn
.
disconnect
FromMain
()
running
=
null
running
=
null
}
}
...
...
core/src/main/java/com/github/shadowsocks/utils/Utils.kt
View file @
e8127920
...
@@ -36,6 +36,10 @@ import android.util.TypedValue
...
@@ -36,6 +36,10 @@ import android.util.TypedValue
import
androidx.annotation.AttrRes
import
androidx.annotation.AttrRes
import
androidx.preference.Preference
import
androidx.preference.Preference
import
com.crashlytics.android.Crashlytics
import
com.crashlytics.android.Crashlytics
import
kotlinx.coroutines.Dispatchers
import
kotlinx.coroutines.GlobalScope
import
kotlinx.coroutines.launch
import
java.net.HttpURLConnection
import
java.net.InetAddress
import
java.net.InetAddress
private
val
parseNumericAddress
by
lazy
{
private
val
parseNumericAddress
by
lazy
{
...
@@ -51,6 +55,10 @@ private val parseNumericAddress by lazy {
...
@@ -51,6 +55,10 @@ private val parseNumericAddress by lazy {
fun
String
?.
parseNumericAddress
():
InetAddress
?
=
Os
.
inet_pton
(
OsConstants
.
AF_INET
,
this
)
fun
String
?.
parseNumericAddress
():
InetAddress
?
=
Os
.
inet_pton
(
OsConstants
.
AF_INET
,
this
)
?:
Os
.
inet_pton
(
OsConstants
.
AF_INET6
,
this
)
?.
let
{
parseNumericAddress
.
invoke
(
null
,
this
)
as
InetAddress
}
?:
Os
.
inet_pton
(
OsConstants
.
AF_INET6
,
this
)
?.
let
{
parseNumericAddress
.
invoke
(
null
,
this
)
as
InetAddress
}
fun
HttpURLConnection
.
disconnectFromMain
()
{
if
(
Build
.
VERSION
.
SDK_INT
>=
26
)
disconnect
()
else
GlobalScope
.
launch
(
Dispatchers
.
IO
)
{
disconnect
()
}
}
fun
parsePort
(
str
:
String
?,
default
:
Int
,
min
:
Int
=
1025
):
Int
{
fun
parsePort
(
str
:
String
?,
default
:
Int
,
min
:
Int
=
1025
):
Int
{
val
value
=
str
?.
toIntOrNull
()
?:
default
val
value
=
str
?.
toIntOrNull
()
?:
default
return
if
(
value
<
min
||
value
>
65535
)
default
else
value
return
if
(
value
<
min
||
value
>
65535
)
default
else
value
...
...
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