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
79f40b88
Commit
79f40b88
authored
Nov 12, 2017
by
Mygod
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement connection test for proxy modes
parent
13ef297a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
9 deletions
+12
-9
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+0
-1
mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala
.../src/main/scala/com/github/shadowsocks/MainActivity.scala
+12
-8
No files found.
mobile/src/main/res/values/strings.xml
View file @
79f40b88
...
...
@@ -127,7 +127,6 @@
<string
name=
"received"
>
Received:
</string>
<string
name=
"connecting"
>
Connecting…
</string>
<string
name=
"vpn_connected"
>
Connected, tap to check connection
</string>
<string
name=
"nat_connected"
>
Connected
</string>
<string
name=
"not_connected"
>
Not connected
</string>
<!-- acl -->
...
...
mobile/src/main/scala/com/github/shadowsocks/MainActivity.scala
View file @
79f40b88
...
...
@@ -21,7 +21,7 @@
package
com.github.shadowsocks
import
java.lang.System.currentTimeMillis
import
java.net.
{
HttpURLConnection
,
URL
}
import
java.net.
{
HttpURLConnection
,
InetSocketAddress
,
URL
,
Proxy
=>
JavaProxy
}
import
java.util.Locale
import
android.app.Activity
...
...
@@ -119,7 +119,7 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
if
(
state
==
ServiceState
.
CONNECTING
)
fabProgressCircle
.
beginFinalAnimation
()
else
fabProgressCircle
.
postDelayed
(
hideCircle
,
1000
)
fab
.
setImageResource
(
R
.
drawable
.
ic_start_connected
)
statusText
.
setText
(
if
(
app
.
usingVpnMode
)
R
.
string
.
vpn_connected
else
R
.
string
.
nat
_connected
)
statusText
.
setText
(
R
.
string
.
vpn
_connected
)
case
ServiceState
.
STOPPING
=>
fab
.
setImageResource
(
R
.
drawable
.
ic_start_busy
)
if
(
state
==
ServiceState
.
CONNECTED
)
fabProgressCircle
.
show
()
// ignore for stopped
...
...
@@ -242,17 +242,21 @@ class MainActivity extends Activity with ServiceBoundContext with Drawer.OnDrawe
txRateText
=
findViewById
(
R
.
id
.
txRate
).
asInstanceOf
[
TextView
]
rxText
=
findViewById
(
R
.
id
.
rx
).
asInstanceOf
[
TextView
]
rxRateText
=
findViewById
(
R
.
id
.
rxRate
).
asInstanceOf
[
TextView
]
findViewById
[
View
](
R
.
id
.
stat
).
setOnClickListener
(
_
=>
if
(
state
==
ServiceState
.
CONNECTED
&&
app
.
usingVpnMode
)
{
findViewById
[
View
](
R
.
id
.
stat
).
setOnClickListener
(
_
=>
if
(
state
==
ServiceState
.
CONNECTED
)
{
testCount
+=
1
statusText
.
setText
(
R
.
string
.
connection_test_testing
)
val
id
=
testCount
// it would change by other code
Utils
.
ThrowableFuture
{
// Based on: https://android.googlesource.com/platform/frameworks/base/+/master/services/core/java/com/android/server/connectivity/NetworkMonitor.java#640
autoDisconnect
(
new
URL
(
"https"
,
app
.
currentProfile
.
get
.
route
match
{
case
Acl
.
CHINALIST
=>
"www.qualcomm.cn"
case
_
=>
"www.google.com"
},
"/generate_204"
).
openConnection
()
.
asInstanceOf
[
HttpURLConnection
])
{
conn
=>
autoDisconnect
{
val
url
=
new
URL
(
"https"
,
app
.
currentProfile
.
get
.
route
match
{
case
Acl
.
CHINALIST
=>
"www.qualcomm.cn"
case
_
=>
"www.google.com"
},
"/generate_204"
)
(
if
(
app
.
usingVpnMode
)
url
.
openConnection
()
else
url
.
openConnection
(
new
JavaProxy
(
JavaProxy
.
Type
.
SOCKS
,
new
InetSocketAddress
(
"127.0.0.1"
,
app
.
dataStore
.
portProxy
))))
.
asInstanceOf
[
HttpURLConnection
]
}
{
conn
=>
conn
.
setConnectTimeout
(
5
*
1000
)
conn
.
setReadTimeout
(
5
*
1000
)
conn
.
setInstanceFollowRedirects
(
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