From 497a74760d398c817399b3163a95149e9105411a Mon Sep 17 00:00:00 2001 From: Mygod Date: Fri, 8 Dec 2017 17:16:39 -0800 Subject: [PATCH] Refine #1489 --- .../java/com/github/shadowsocks/bg/BaseService.kt | 12 +++++++++--- .../com/github/shadowsocks/bg/LocalDnsService.kt | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt b/mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt index 4b08bea0..65895f72 100644 --- a/mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt +++ b/mobile/src/main/java/com/github/shadowsocks/bg/BaseService.kt @@ -221,10 +221,10 @@ object BaseService { "-t", "600", "-c", "shadowsocks.json")) - val route = data.profile!!.route - if (route != Acl.ALL) { + val acl = getAclFile() + if (acl != null) { cmd += "--acl" - cmd += Acl.getFile(if (route == Acl.CUSTOM_RULES) Acl.CUSTOM_RULES_FLATTENED else route).absolutePath + cmd += acl.absolutePath } if (TcpFastOpen.sendEnabled) cmd += "--fast-open" @@ -232,6 +232,12 @@ object BaseService { data.sslocalProcess = GuardedProcess(cmd).start() } + fun getAclFile(): File? { + val route = data.profile!!.route + return if (route == Acl.ALL) null else + Acl.getFile(if (route == Acl.CUSTOM_RULES) Acl.CUSTOM_RULES_FLATTENED else route) + } + fun createNotification(): ServiceNotification fun startRunner() { diff --git a/mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt b/mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt index 1796495c..5de7aabc 100644 --- a/mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt +++ b/mobile/src/main/java/com/github/shadowsocks/bg/LocalDnsService.kt @@ -89,7 +89,7 @@ object LocalDnsService { .put("PrimaryDNS", localDns) .put("AlternativeDNS", remoteDns) .put("IPNetworkFile", "china_ip_list.txt") - .put("DomainFile", app.filesDir.absolutePath + "/" + profile.route + ".acl") + .put("DomainFile", getAclFile()!!.absolutePath) Acl.CHINALIST -> config .put("PrimaryDNS", localDns) .put("AlternativeDNS", remoteDns)