Commit 10238707 authored by Max Lv's avatar Max Lv

refine DNS resolver on Lollipop

parent 72824eb8
Subproject commit 271d55942c943c3813638a19a7194ca062ba6fe3 Subproject commit 1008cf1f5bb0004c64a86b103c157ec98c177cd6
...@@ -75,7 +75,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -75,7 +75,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
private lazy val application = getApplication.asInstanceOf[ShadowsocksApplication] private lazy val application = getApplication.asInstanceOf[ShadowsocksApplication]
def isACLEnabled: Boolean = { def isLollipopOrAbove: Boolean = {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
true true
} else { } else {
...@@ -90,7 +90,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -90,7 +90,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def startShadowsocksDaemon() { def startShadowsocksDaemon() {
if (isACLEnabled && config.isGFWList) { if (isLollipopOrAbove && config.isGFWList) {
val chn_list: Array[String] = getResources.getStringArray(R.array.chn_list_full) val chn_list: Array[String] = getResources.getStringArray(R.array.chn_list_full)
ConfigUtils.printToFile(new File(Path.BASE + "chn.acl"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "chn.acl"))(p => {
chn_list.foreach(item => p.println(item)) chn_list.foreach(item => p.println(item))
...@@ -107,7 +107,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -107,7 +107,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
, "-m" , config.encMethod , "-m" , config.encMethod
, "-f" , Path.BASE + "ss-local.pid") , "-f" , Path.BASE + "ss-local.pid")
if (config.isGFWList && isACLEnabled) { if (config.isGFWList && isLollipopOrAbove) {
cmd += "--acl" cmd += "--acl"
cmd += (Path.BASE + "chn.acl") cmd += (Path.BASE + "chn.acl")
} }
...@@ -133,8 +133,12 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -133,8 +133,12 @@ class ShadowsocksVpnService extends VpnService with BaseService {
def startDnsDaemon() { def startDnsDaemon() {
val conf = { val conf = {
if (isLollipopOrAbove) {
ConfigUtils.PDNSD_BYPASS.format("0.0.0.0", getString(R.string.exclude), 8163)
} else {
ConfigUtils.PDNSD_LOCAL.format("0.0.0.0", 8163) ConfigUtils.PDNSD_LOCAL.format("0.0.0.0", 8163)
} }
}
ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => { ConfigUtils.printToFile(new File(Path.BASE + "pdnsd.conf"))(p => {
p.println(conf) p.println(conf)
}) })
...@@ -164,7 +168,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -164,7 +168,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
.addAddress(PRIVATE_VLAN.format("1"), 24) .addAddress(PRIVATE_VLAN.format("1"), 24)
.addDnsServer("8.8.8.8") .addDnsServer("8.8.8.8")
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP) { if (isLollipopOrAbove) {
if (!config.isGlobalProxy) { if (!config.isGlobalProxy) {
val apps = AppManager.getProxiedApps(this, config.proxiedAppString) val apps = AppManager.getProxiedApps(this, config.proxiedAppString)
val pkgSet: mutable.HashSet[String] = new mutable.HashSet[String] val pkgSet: mutable.HashSet[String] = new mutable.HashSet[String]
...@@ -191,7 +195,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -191,7 +195,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
if (InetAddressUtils.isIPv6Address(config.proxy)) { if (InetAddressUtils.isIPv6Address(config.proxy)) {
builder.addRoute("0.0.0.0", 0) builder.addRoute("0.0.0.0", 0)
} else if (!isACLEnabled && config.isGFWList) { } else if (!isLollipopOrAbove && config.isGFWList) {
val gfwList = { val gfwList = {
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) { if (Build.VERSION.SDK_INT == Build.VERSION_CODES.KITKAT) {
getResources.getStringArray(R.array.simple_list) getResources.getStringArray(R.array.simple_list)
...@@ -207,7 +211,7 @@ class ShadowsocksVpnService extends VpnService with BaseService { ...@@ -207,7 +211,7 @@ class ShadowsocksVpnService extends VpnService with BaseService {
} }
}) })
} else { } else {
if (isACLEnabled) { if (isLollipopOrAbove) {
builder.addRoute("0.0.0.0", 0) builder.addRoute("0.0.0.0", 0)
} else { } else {
for (i <- 1 to 223) { for (i <- 1 to 223) {
......
...@@ -142,7 +142,7 @@ object ConfigUtils { ...@@ -142,7 +142,7 @@ object ConfigUtils {
| |
|server { |server {
| label = "china-servers"; | label = "china-servers";
| ip = 114.114.114.114, 114.114.115.115; | ip = 114.114.114.114, 223.5.5.5;
| uptest = none; | uptest = none;
| preset = on; | preset = on;
| include = %s; | include = %s;
...@@ -151,8 +151,9 @@ object ConfigUtils { ...@@ -151,8 +151,9 @@ object ConfigUtils {
|} |}
| |
|server { |server {
| label = "google-servers"; | label = "local-server";
| ip = 8.8.8.8, 8.8.4.4; | ip = 127.0.0.1;
| port = %d;
| timeout = 5; | timeout = 5;
|} |}
| |
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment