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
a865ee83
Commit
a865ee83
authored
Dec 27, 2016
by
Max Lv
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace HttpRequest with OkHttp3
parent
5419b4b5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
9 deletions
+40
-9
build.sbt
build.sbt
+4
-1
src/main/res/raw/gtm_default_container
src/main/res/raw/gtm_default_container
+0
-0
src/main/scala/com/github/shadowsocks/BaseService.scala
src/main/scala/com/github/shadowsocks/BaseService.scala
+36
-8
No files found.
build.sbt
View file @
a865ee83
...
@@ -20,6 +20,9 @@ proguardVersion := "5.3.2"
...
@@ -20,6 +20,9 @@ proguardVersion := "5.3.2"
proguardCache
:=
Seq
()
proguardCache
:=
Seq
()
proguardOptions
++=
proguardOptions
++=
"-keep class com.github.shadowsocks.System { *; }"
::
"-keep class com.github.shadowsocks.System { *; }"
::
"-keep class okhttp3.** { *; }"
::
"-keep interface okhttp3.** { *; }"
::
"-dontwarn okio.**"
::
"-dontwarn com.google.android.gms.internal.**"
::
"-dontwarn com.google.android.gms.internal.**"
::
"-dontwarn com.j256.ormlite.**"
::
"-dontwarn com.j256.ormlite.**"
::
"-dontwarn org.xbill.**"
::
"-dontwarn org.xbill.**"
::
...
@@ -37,7 +40,7 @@ libraryDependencies ++=
...
@@ -37,7 +40,7 @@ libraryDependencies ++=
"com.android.support"
%
"preference-v14"
%
"25.1.0"
::
"com.android.support"
%
"preference-v14"
%
"25.1.0"
::
"com.evernote"
%
"android-job"
%
"1.1.3"
::
"com.evernote"
%
"android-job"
%
"1.1.3"
::
"com.github.jorgecastilloprz"
%
"fabprogresscircle"
%
"1.01"
::
"com.github.jorgecastilloprz"
%
"fabprogresscircle"
%
"1.01"
::
"com.
github.kevinsawicki"
%
"http-request"
%
"6
.0"
::
"com.
squareup.okhttp3"
%
"okhttp"
%
"3.5
.0"
::
"com.google.android.gms"
%
"play-services-ads"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-ads"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-analytics"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-analytics"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
"com.google.android.gms"
%
"play-services-gcm"
%
"10.0.1"
::
...
...
src/main/res/raw/gtm_default_container
View file @
a865ee83
No preview for this file type
src/main/scala/com/github/shadowsocks/BaseService.scala
View file @
a865ee83
...
@@ -21,7 +21,9 @@
...
@@ -21,7 +21,9 @@
package
com.github.shadowsocks
package
com.github.shadowsocks
import
java.io.IOException
import
java.io.IOException
import
java.util.
{
Timer
,
TimerTask
}
import
java.util.concurrent.TimeUnit
;
import
java.util.
{
Arrays
,
List
,
Timer
,
TimerTask
}
import
java.net.InetAddress
import
android.app.Service
import
android.app.Service
import
android.content.
{
BroadcastReceiver
,
Context
,
Intent
,
IntentFilter
}
import
android.content.
{
BroadcastReceiver
,
Context
,
Intent
,
IntentFilter
}
...
@@ -30,12 +32,26 @@ import android.os.{Handler, RemoteCallbackList}
...
@@ -30,12 +32,26 @@ import android.os.{Handler, RemoteCallbackList}
import
android.text.TextUtils
import
android.text.TextUtils
import
android.util.Log
import
android.util.Log
import
android.widget.Toast
import
android.widget.Toast
import
com.github.kevinsawicki.http.HttpRequest
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.ShadowsocksApplication.app
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
import
com.github.shadowsocks.aidl.
{
IShadowsocksService
,
IShadowsocksServiceCallback
}
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.database.Profile
import
com.github.shadowsocks.utils._
import
com.github.shadowsocks.utils._
import
okhttp3.Dns
import
okhttp3.FormBody
import
okhttp3.OkHttpClient
import
okhttp3.Request
import
okhttp3.Response
class
CustomDns
extends
Dns
{
override
def
lookup
(
hostname
:
String
)
:
List
[
InetAddress
]
=
{
Utils
.
resolve
(
hostname
,
false
)
match
{
case
Some
(
ip
)
=>
Arrays
.
asList
(
InetAddress
.
getByName
(
ip
))
case
_
=>
Dns
.
SYSTEM
.
lookup
(
hostname
)
}
}
}
trait
BaseService
extends
Service
{
trait
BaseService
extends
Service
{
@volatile
private
var
state
=
State
.
STOPPED
@volatile
private
var
state
=
State
.
STOPPED
...
@@ -132,12 +148,24 @@ trait BaseService extends Service {
...
@@ -132,12 +148,24 @@ trait BaseService extends Service {
val
container
=
holder
.
getContainer
val
container
=
holder
.
getContainer
val
url
=
container
.
getString
(
"proxy_url"
)
val
url
=
container
.
getString
(
"proxy_url"
)
val
sig
=
Utils
.
getSignature
(
this
)
val
sig
=
Utils
.
getSignature
(
this
)
val
list
=
HttpRequest
.
post
(
url
)
val
client
=
new
OkHttpClient
.
Builder
()
.
connectTimeout
(
2000
)
.
dns
(
new
CustomDns
())
.
readTimeout
(
2000
)
.
connectTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
send
(
"sig="
+
sig
)
.
writeTimeout
(
10
,
TimeUnit
.
SECONDS
)
.
body
.
readTimeout
(
30
,
TimeUnit
.
SECONDS
)
.
build
()
val
requestBody
=
new
FormBody
.
Builder
()
.
add
(
"sig"
,
sig
)
.
build
()
val
request
=
new
Request
.
Builder
()
.
url
(
url
)
.
post
(
requestBody
)
.
build
()
val
resposne
=
client
.
newCall
(
request
).
execute
()
val
list
=
resposne
.
body
.
string
val
proxies
=
util
.
Random
.
shuffle
(
list
.
split
(
'|'
).
toSeq
)
val
proxies
=
util
.
Random
.
shuffle
(
list
.
split
(
'|'
).
toSeq
)
val
proxy
=
proxies
.
head
.
split
(
':'
)
val
proxy
=
proxies
.
head
.
split
(
':'
)
profile
.
host
=
proxy
(
0
).
trim
profile
.
host
=
proxy
(
0
).
trim
...
...
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