Refine "Replace HttpRequest with OkHttp3"

This commit is contained in:
Mygod
2016-12-27 23:36:30 +08:00
parent e782a4c777
commit a4f326157d
2 changed files with 6 additions and 19 deletions
+1 -1
View File
@@ -46,7 +46,7 @@ libraryDependencies ++=
"com.google.android.gms" % "play-services-gcm" % "10.0.1" ::
"com.j256.ormlite" % "ormlite-android" % "5.0" ::
"com.mikepenz" % "fastadapter" % "2.1.5" ::
"com.mikepenz" % "iconics-core" % "2.8.1" ::
"com.mikepenz" % "iconics-core" % "2.8.2" ::
"com.mikepenz" % "materialdrawer" % "5.8.1" ::
"com.mikepenz" % "materialize" % "1.0.0" ::
"com.twofortyfouram" % "android-plugin-api-for-locale" % "1.0.2" ::
@@ -21,9 +21,8 @@
package com.github.shadowsocks
import java.io.IOException
import java.util.concurrent.TimeUnit;
import java.util.{Arrays, List, Timer, TimerTask}
import java.net.InetAddress
import java.util.concurrent.TimeUnit
import java.util.{Timer, TimerTask}
import android.app.Service
import android.content.{BroadcastReceiver, Context, Intent, IntentFilter}
@@ -36,21 +35,9 @@ import com.github.shadowsocks.ShadowsocksApplication.app
import com.github.shadowsocks.aidl.{IShadowsocksService, IShadowsocksServiceCallback}
import com.github.shadowsocks.database.Profile
import com.github.shadowsocks.utils._
import okhttp3.{FormBody, OkHttpClient, Request}
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)
}
}
}
import scala.util.Random
trait BaseService extends Service {
@@ -166,7 +153,7 @@ trait BaseService extends Service {
val resposne = client.newCall(request).execute()
val list = resposne.body.string
val proxies = util.Random.shuffle(list.split('|').toSeq)
val proxies = Random.shuffle(list.split('|').toSeq)
val proxy = proxies.head.split(':')
profile.host = proxy(0).trim
profile.remotePort = proxy(1).trim.toInt