Add option: bypass China only
Fix #569. It could have worked without upgrading database by using an option called `bypass-china-only`. But I think we will get better readability this way.
This commit is contained in:
@@ -44,7 +44,6 @@ import java.lang.Process
|
||||
import java.net.{Inet6Address, InetAddress}
|
||||
import java.util.Locale
|
||||
|
||||
import android.app.Service
|
||||
import android.content._
|
||||
import android.content.pm.{PackageInfo, PackageManager}
|
||||
import android.net.{ConnectivityManager, Network}
|
||||
@@ -164,12 +163,14 @@ class ShadowsocksNatService extends BaseService {
|
||||
|
||||
def startShadowsocksDaemon() {
|
||||
if (config.route != Route.ALL) {
|
||||
val acl: Array[String] = config.route match {
|
||||
case Route.BYPASS_LAN => getResources.getStringArray(R.array.private_route)
|
||||
case Route.BYPASS_CHN => getResources.getStringArray(R.array.chn_route_full)
|
||||
val acl: Array[Array[String]] = config.route match {
|
||||
case Route.BYPASS_LAN => Array(getResources.getStringArray(R.array.private_route))
|
||||
case Route.BYPASS_CHN => Array(getResources.getStringArray(R.array.chn_route))
|
||||
case Route.BYPASS_LAN_CHN =>
|
||||
Array(getResources.getStringArray(R.array.private_route), getResources.getStringArray(R.array.chn_route))
|
||||
}
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo.dataDir + "/acl.list"))(p => {
|
||||
acl.foreach(item => p.println(item))
|
||||
acl.flatten.foreach(p.println)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -273,12 +273,14 @@ class ShadowsocksVpnService extends VpnService with BaseService {
|
||||
def startShadowsocksDaemon() {
|
||||
|
||||
if (config.route != Route.ALL) {
|
||||
val acl: Array[String] = config.route match {
|
||||
case Route.BYPASS_LAN => getResources.getStringArray(R.array.private_route)
|
||||
case Route.BYPASS_CHN => getResources.getStringArray(R.array.chn_route_full)
|
||||
val acl: Array[Array[String]] = config.route match {
|
||||
case Route.BYPASS_LAN => Array(getResources.getStringArray(R.array.private_route))
|
||||
case Route.BYPASS_CHN => Array(getResources.getStringArray(R.array.chn_route))
|
||||
case Route.BYPASS_LAN_CHN =>
|
||||
Array(getResources.getStringArray(R.array.private_route), getResources.getStringArray(R.array.chn_route))
|
||||
}
|
||||
ConfigUtils.printToFile(new File(getApplicationInfo.dataDir + "/acl.list"))(p => {
|
||||
acl.foreach(item => p.println(item))
|
||||
acl.flatten.foreach(p.println)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ object DBHelper {
|
||||
}
|
||||
|
||||
class DBHelper(val context: Context)
|
||||
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 15) {
|
||||
extends OrmLiteSqliteOpenHelper(context, DBHelper.PROFILE, null, 16) {
|
||||
import DBHelper._
|
||||
|
||||
lazy val profileDao: Dao[Profile, Int] = getDao(classOf[Profile])
|
||||
@@ -121,6 +121,10 @@ class DBHelper(val context: Context)
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
|
||||
if (oldVersion < 16) {
|
||||
profileDao.executeRawNoArgs("UPDATE `profile` SET route = 'bypass-lan-china' WHERE route = 'bypass-china'")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,4 +110,5 @@ object Route {
|
||||
val ALL = "all"
|
||||
val BYPASS_LAN = "bypass-lan"
|
||||
val BYPASS_CHN = "bypass-china"
|
||||
val BYPASS_LAN_CHN = "bypass-lan-china"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user