refine proxy list refresing
This commit is contained in:
@@ -2,7 +2,8 @@ libraryDependencies ++= Seq(
|
||||
"com.google.android" % "support-v4" % "r12",
|
||||
"com.google.android" % "analytics" % "3.01",
|
||||
"com.google.android" % "admob" % "6.4.1",
|
||||
"dnsjava" % "dnsjava" % "2.1.5"
|
||||
"dnsjava" % "dnsjava" % "2.1.5",
|
||||
"org.scalaj" %% "scalaj-http" % "0.3.10"
|
||||
)
|
||||
|
||||
libraryDependencies ++= Seq(
|
||||
|
||||
@@ -191,13 +191,15 @@ class ShadowVpnService extends VpnService {
|
||||
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val container = getApplication.asInstanceOf[ShadowsocksApplication].tagContainer
|
||||
if (container == null) {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
stopSelf()
|
||||
handler.sendEmptyMessageDelayed(MSG_CONNECT_FAIL, 500)
|
||||
return
|
||||
} else {
|
||||
try {
|
||||
config = Config.getPublicConfig(container, config)
|
||||
} catch {
|
||||
case ex: Exception => {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
stopSelf()
|
||||
handler.sendEmptyMessageDelayed(MSG_CONNECT_FAIL, 500)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -227,13 +227,15 @@ class ShadowsocksService extends Service {
|
||||
|
||||
if (config.proxy == "198.199.101.152") {
|
||||
val container = getApplication.asInstanceOf[ShadowsocksApplication].tagContainer
|
||||
if (container == null) {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
stopSelf()
|
||||
handler.sendEmptyMessageDelayed(MSG_CONNECT_FAIL, 500)
|
||||
return
|
||||
} else {
|
||||
try {
|
||||
config = Config.getPublicConfig(container, config)
|
||||
} catch {
|
||||
case ex: Exception => {
|
||||
notifyAlert(getString(R.string.forward_fail), getString(R.string.service_failed))
|
||||
stopSelf()
|
||||
handler.sendEmptyMessageDelayed(MSG_CONNECT_FAIL, 500)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import android.app.ActivityManager
|
||||
import android.os.Build
|
||||
import android.provider.Settings
|
||||
import scala.Some
|
||||
import scalaj.http.{Http, HttpOptions}
|
||||
import com.google.tagmanager.Container
|
||||
|
||||
object Config {
|
||||
@@ -117,7 +118,8 @@ object Config {
|
||||
}
|
||||
|
||||
def getPublicConfig(container: Container, config: Config): Config = {
|
||||
val list = container.getString("proxy_list")
|
||||
val url = container.getString("proxy_url")
|
||||
val list = Http(url).option(HttpOptions.connTimeout(1000)).option(HttpOptions.readTimeout(5000)).asString
|
||||
val proxies = util.Random.shuffle(list.split('|').toSeq).toSeq
|
||||
val proxy = proxies(0).split(':')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user